tinode / chat

Instant messaging platform. Backend in Go. Clients: Swift iOS, Java Android, JS webapp, scriptable command line; chatbots
GNU General Public License v3.0
12.06k stars 1.88k forks source link

how do you keep the session connection #117

Closed xingguangkuo closed 6 years ago

xingguangkuo commented 6 years ago

How can we keep the one to one message channel connected by Tinodejs? After I first connected to the server, after a while I judged whether the connection was there, the return value of the connection was null. I use the Vue framework +Tinodejs to send the message to the other party for the first piece of data that can be received, but the next message will not be collected over a period of time.

Tinode.Tinode.isConnected () Log:null

So every time I send messages, I have to reconnect to login to send messages. At the JS level, how do you keep the session connection? Solve this problem in trouble. Thank you!

or-else commented 6 years ago

tinode.js keeps connection open just fine. You can open https://api.tinode.co/x/example-react-js/# and see that the connection stays open for 24 hours until the server is reset. So obviously you are doing something wrong and I cannot help you debug your code without seeing it.

xingguangkuo commented 6 years ago

Sub to 'me' from 'usrctNBS3OGhFE' sess.readLoop: websocket: close 1005 (no status) serveWebsocket - stop Session.dispatch got '{"hi":{"id":"113263","ver":"0.15","ua":"TinodeWeb/0.15 (Safari/601.1; Win32); tinodejs/0.15"}}' from '182.48.107.122:45115' Session.dispatch got '{"login":{"id":"113264","scheme":"basic","secret":"Szh3WWpXWHA6N1dDZGg4R04="}}' from '182.48.107.122:45115' Session.dispatch got '{"sub":{"id":"113265","topic":"me","get":{"what":"sub desc"}}}' from '182.48.107.122:45115' case Sub to 'me' from 'usrd2R9ck8EXmo' Sub to 'me' from 'usrd2R9ck8EXmo' sess.writeLoop: ping/websocket: close sent sess.writeLoop: ping/websocket: close sent sess.readLoop: websocket: close 1005 (no status) serveWebsocket - stop Session.dispatch got '{"hi":{"id":"107291","ver":"0.15","ua":"TinodeWeb/0.15 (Safari/601.1; Win32); tinodejs/0.15"}}' from '182.48.107.122:45468' Session.dispatch got '{"login":{"id":"107292","scheme":"basic","secret":"Ym9iOmJvYjEyMw=="}}' from '182.48.107.122:45468' Session.dispatch got '{"sub":{"id":"107293","topic":"me","get":{"what":"sub desc"}}}' from '182.48.107.122:45468' case Sub to 'me' from 'usrctNBS3OGhFE' Sub to 'me' from 'usrctNBS3OGhFE' sess.readLoop: websocket: close 1005 (no status)

I run the go run environment log? Is it right that websocket is often closed?