I am working on websocket connection and I am using SocketRocket(https://github.com/square/SocketRocket) library for that, I am got successful in connecting with server, but connection gets disconnected at every few seconds. I dont know why this is happening as I want a persistent connection and Websockets are for that only
Help me if possible.
Thanks
Related
I'm writing a chat app using Twilio's Programmable Chat JS SDK. The app works fine, but I noticed after some long time (maybe 30+ minutes) where the browser tab is inactive, when I return to the browser tab the websocket connection is closed. These are the messages that appear in the console after switching to the inactive browser tab:
WebSocket connection to 'wss://tsock.us1.twilio.com/v3/wsconnect' failed: Error
in connection establishment: net::ERR_INTERNET_DISCONNECTED
twilio-chat.min.js:204 WebSocket connection to
'wss://tsock.us1.twilio.com/v3/wsconnect' failed: WebSocket is closed before
the connection is established.
1) Is this normal? Does it have to do with the fact that I'm still on the Twilio Free Plan?
2) How to manage socket connections in these cases? Also if the internet connection is lost then reestablished, how to ensure the web socket reconnects?
I tried to listen to the connectionStateChanged event as per the SDK docs here:
http://media.twiliocdn.com/sdk/js/chat/releases/3.2.0/docs/Client.html#event:connectionStateChanged
but when the user's device is sleeping (e.g. laptop in sleep mode) the event will not fire and therefore the socket will close.
Thanks
Was a known bug from Twilio. Solved by updating to the JS SDK 3.2.
I am using socket connection in my app. The app is working fine while the connection is fine.
While the internet is gone for 5 seconds and comes back then I am not able to detect immediately connection is lost.
Use heartbeat package to detect if there is a connection! and reconnect or handle error when connection lost.
When my project running face recognition module will continue to output:
Missing server connection for kCTConnectionInvalidatedNotification.
What could be causing the issue? how can I resolve it?
If you used some socket connection , you have to pay attention:
To send heart bit package periodically to your server.
When client loses client, you have to reconnect to your server (unless you don't want it).
I am using the socket.io NodeJs server library and the Swift client library. Majority of the time the client successfully reconnects to the server after a disconnection, however intermittently we are seeing abrupt disconnections and then the client is never able to reconnect.
In the server logs, I see the client sending a connection attempt at the defined re-try interval, however it just never successfully establishes the connection and then we get a ping timeout.
There is surprisingly very little support for Socket.io which makes this extremely difficult to solve.
I figured out a solution to our problem by forcing a new engine to be created in the client upon reconnections. When creating the SocketIOClient object, set the forceNew variable to true which allows the client to create a new engine and thus always successfully establishes the connection.
return SocketIOClient(socketURL: socketURL, config: [.forceNew(true)])
I am running Wildfly 8.2 instance with HornetQ messaging remotely accessible via HTTPS on port 8185.
For testing the connection I am running a client on the same machine connecting via https-remoting://localhost:8185
from client view everything works fine: connecting, sending / receiving messages and closing connection
on server side at first all works fine, too. However, after period set in "connection-ttl" of RemoteConnectionFactory has passed, server logs following lines:
2015-09-03 17:05:49,152 WARN [org.hornetq.core.client] (hornetq-failure-check-thread) HQ212037: Connection failure has been detected: HQ119014: Did not receive data from /192.168.160.83:63937. It is likely the client has exited or crashed without closing its connection, or the network between the server and client has failed. You also might have configured connection-ttl and client-failure-check-period incorrectly. Please check user manual for more information. The connection will now be closed. [code=CONNECTION_TIMEDOUT]
2015-09-03 17:05:49,154 INFO [org.hornetq.core.server] (hornetq-failure-check-thread) HQ221021: failed to remove connection
Final result after testing for a longer time (every 1-2 seconds clients are connecting, sending / receiving messages, closing the connection):
Wildfly consumes more and more heap memory and finally stops working with an OutOfMemoryError ...
As mentioned, the connections are always explicitly closed by client, and at closing time no error is logged, neither on client nor on server side. It seems that the "hornetq-failure-check-thread" just didn't get informed that the connection was already closed
Any help for this issue is appreciated!