We are using the Twilio Programmable Chat JavaScript SDK (v. 4.0.0) to build a chat application.
We have several channels for each user and we listen on every channel for messages via the messageAdded-Event.
After a disconnect the client is reconnecting normally, but no events for messages sent in the meantime are fired.
Example:
User A: Client goes offline
User B: Sends message
User A: Client goes online
User A: Client is "connected"
User A: No Event for new message
We would expect that after the client has re-established connection we would get events for the "missed" messages/created channels; especially as the docs state (probably only meant for the client, but whats the point then?):
There is no need to implement shutdown/create cycle on network drops →
SDK reconnects automatically after regaining network.
Is this intended behaviour?
What would be the best way to retrieve "missed" events? Reload channels/messages manually?
(3) Another problem we discovered is, that sometimes the client is not able to reconnect at all, which results in a lot of Retrier attempt is already in progress, Twilsock: request timeout error messages. Any ideas on that?
Related
i am developing a social network with a chat messenger. it's a responsive web application.
the messages are saved on mongo db, and then sent instantly through socket io.
the problem is when computer is sleeping/mobile is locked,
the socket io connection goes off.
and when coming back from sleep/lock mode, the connection doesn't re-create.
let's say a user got couple of messages when his phone was locked, and the webpage was open there waiting for him.
even if i re-connect the socket when user starts interacting with webpage again, still the user will not see the instant messages he was getting, because the messages from mongo arrive only when entering the app for the first time.
the only solution i can think about is that when coming back from sleep, the web page should reset itself and loads again with all the data from mongo db.
do you have any better idea? is auto refreshing after detecting waking up from sleep mode, is even possible?
I'm developing a group voice chat application using WebRTC and React.
I have managed to establish a connection and the voice chat works fine on first connection.
The way it works is like this:
User A joins chat room.
User B joins chat room.
User A enables audio through a toggle button - this notifies the signaling server that they're open for any WebRTC connections.
User B enables audio through a toggle button - they now through the server establish the WebRTC connection process to anyone who has enabled audio (being user A in this case).
This has worked fine so far. My issue is establishing a connection a second time around in the scenario of:
Both users have audio enabled. Voice comms working fine.
User B toggles audio - disabling it. User A remains active.
User B toggles audio again to reconnect to user A.
I get the following error:
DOMException: Failed to execute 'setRemoteDescription' on 'RTCPeerConnection': Failed to set remote answer sdp: Called in wrong state: kStable
I understand this error means that there's an issue with the connection order. So I figured this could be to do with not having a adequate disconnection process.
So I implemented a feature that when User B disables audio, it sends all other users in the room a message to remove that persons Peer_Connection object from the peer conection array on each users local state. But this is to no avail.
I'm confused as to why this is happening because if I exit the chat room and re-enter on both users, the connection can be re-established once more, so I assume it has something to do with there being remnants of the old connection causing issues with the new.
(It also works if both users have audio enabled, the one disables, leaves the room, comes back and enables all while the first user had it enabled the whole time. So an error on part with the client who sends the offer?)
As always, any tips and help would be appreciated, thank you.
Reconnection was not possible. For anyone seeking a solution for a similar issue:
Instead of reconnection, simple disable the audiotracks. Locally this means no one gets any audio feed from you. Disabling remote audiotracks mutes the audio for yourself obviously. Muting both means there's no audio coming in or out, which can simulate a disconnection with a toggle switch while the person remains in the same room.
In my scenario, I am using SignalR for login purpose.
If user one is logged in with username 'abc' and user two login with the username 'abc', user one will be kicked and redirect two login page.
But if user one is logged in and it refreshes the page and then user two tries to logged in user one will not get kicked. Because while refreshing user one has lost the connection. I tried lots of solutions like trying to reconnect on disconnect event, but its not working.
Can anyone help in this?
Client Disconnection Scenarios
In a browser client, the SignalR client code that maintains a SignalR connection runs in the JavaScript context of a web page
When the user closes a browser window or tab, or navigates to a new page or refreshes the page, the SignalR connection immediately ends because SignalR client code handles that browser event for you and calls the Stop method. In these scenarios, or in any client platform when your application calls the Stop method, the OnDisconnected event handler executes immediately on the server and the client raises the Closed event (the event is named disconnected in JavaScript)
Disconnection Scenarios(Client & Server)
Let's say worker X logged in to our call center app and went online in twilio. He will now be able to receive reservations and respond to people. X lives in a third world country where the internet connection is very unreliable. His internet suddenly cut off while online and he is no longer able to respond to reservations. His activity is still Online and he has no way of changing it because he doesn't have an internet connection. Is there a way to tell twilio to go Offline when the WebSocket connection is lost between the client and the server?
I'm aware that we have disconnectActivitySid in TaskRouter.js but it is only fired on window.unload event and doesn't cover the cases where the browser crashes or we have internet connectivity problems.
Twilio developer evangelist here.
The only way to do this today would be to have the Worker receive a next Reservation, but have a Workflow ReservationTimeout of a semi-low value (10-15 seconds) and to utilize the Workspace’s TimeoutActivitySid to push the Worker to Offline.
With that setup, if the Worker loses connection (but is Idle), and receives a Reservation and is able to reconnect before that Reservation Times out (in that 15 second window), they will presented the Reservation with the JS SDK. So nothing will be lost. If they do not reconnect within that timeout window, the Worker will be pushed to Offline, and another Worker will be eligible to pick up the Task.
Let me know if that helps at all.
I know this one has probably been asked before, but not with the context of push notifications.
I'm developing an app using Ionic/Cordova that sends push notifications to clients, usually about new video messages for them to watch. The videos are not going to be streamed but transferred to the client-side (not my call), so I thought of implementing some background javascript function to store the video on the client-side when and while the push has been received.
I have looked on web-workers and multithreading but it needs the client-side running. The javascript code has an event listener for when pushes are being received, but of course it does not get executed until the app is being opened.
So my question is, is it even possible? I'll appreciate any words of advice on this matter, thanks!
I already did this in my app using signalr together with push notification. My app. is a chat app. that client X can send a rich text message with pictures or video to client Y.
when client X send message, it calls the signalr Server and the Server save the message in Server sql and save the picture or video in Web server.
if client Y is offline, it will get the message during next online. If client Y is already on-line:
case 1: online but in foreground: signalr Server call client Y JavaScript function to update the screen and local storage, client Y see the message and picture immediately. (and I also play a sound)
case 2: online but in background or the mobile phone in screen safe mode: signalr Server call client Y JavaScript function to update the screen and local storage, play another sound. then send a push notification to client Y too! So that when client Y see this notification, it open the app. and see the message in local storage. (just like Whatsapp)