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.
Related
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.
I am developing an iOS VoIP app using Twilio. I need the app to keep listening for incoming connections at all times.
When app is in background, the Twilio library handles keeping the app running. When a disconnection from Twilio happens (due to an expired capability token for example), a delegate method TCDevice:didStopListeningForIncomingConnections is called, and from there I am able to re-establish connection to Twilio. But if the disconnection occurs due to no internet availability, this method will be called when there is no internet connection, and I will not be able to establish the connection such that even if the user reconnected later, I cannot re-establish the connection.
So the Question is: How To Re-establish Connection To Twilio After A Long Internet Disconnection?
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!
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
Am using open fire server and iOS xmpp client with Robbie Hanson's framework. My clients runs fine in background, as i have set the voip flag and everything. But after few hours around 15-20, it automatically gets disconnected. Am not sure why it's happening and why it is taking such long duration. I am not sending any messages or receiving any. The ping interval is 360 secs to which my client responds with an error, which is acceptable form of response to remain connected to the server. Anyone got the same issue ?
Openfire server: 3.8.1
iOS version: 6.1.2
Did you try using the setting "Do Not disconnect clients that are idle" available in Server Settings> Client Connections in Openfire server?