WebSockets connection lost issue

660 views
Skip to first unread message

DHRUPAL PATEL

unread,
Feb 24, 2014, 4:27:42 AM2/24/14
to autob...@googlegroups.com
Hello,

Frequently i am getting in onclose() method. I get code 3 and 5,

What i should to over come this problem. Why it is happening?

Chuck James

unread,
Feb 24, 2014, 10:19:54 AM2/24/14
to autob...@googlegroups.com
Dear friend, it will be better if you will provide some more information. The method you are talking about it's client end or server end, in what class/subclass you are getting this error. Little code will be great way to help us to figure it out for you.

Autobahn is a very stable library as it's builded over twisted. Which is more than a library, for some people it's a technology. In-short this should not be a library issue.

Lots of things cause the disconnection. 
  • First of all check your code, at some point or in some logic you may be disconnecting users or unauthorized users, check if all the disconnected users are falling in that category.
  • Check if it's a secure server and you are just using ws as protocol instead of wss.
  • Some server component could stop your server application and it may be restarting after stopping. So at stop it's disconnecting all the users
  • Your server might be already using it's maximum resources, and it can't handle more connections. Don't forget autobahn can use only one cpu core. 
There could be n numbers of things cause the disconnect, but we can not help you without knowing more about code or scenarios. Is it disconnecting all the user right after the connect or it's after a duration. See if reconnect logic helps you. 


Thanks,
Chuck James

Nick Guenther

unread,
Feb 24, 2014, 11:56:53 AM2/24/14
to autob...@googlegroups.com

And let me add that I found debugging Autobahn frustrating because it
doesn't bubble up exceptions anywhere obvious, but I worked around that
by hooking the websocket's handlers like this:

connection._websocket.onerror = function(evt) {
console.log("websocket error: " + evt.reason)
console.log(evt)
}

connection._websocket.onclose = function(evt) {
console.log("websocket close: " + evt.reason)
console.log(evt)
}

You must put these lines *after* calling connection.open() though,
because AutobahnJS doesn't create ._websocket until then.

By the way, it is easier and much more likely that you will get help if
you can post your code with questions like this. Can you reduce your
code to a single html file with inline javascript plus a single python
server file? If you paste that (say to pastebin or github) then we can
take a look without guessing.



On Mon, Feb 24, 2014 at 10:19 AM, Chuck James <amitab...@gmail.com>
wrote:
> --
> You received this message because you are subscribed to the Google
> Groups "Autobahn" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to autobahnws+...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>

Tobias Oberstein

unread,
Feb 26, 2014, 8:11:53 AM2/26/14
to autob...@googlegroups.com
Am 24.02.2014 17:56, schrieb Nick Guenther:
>
> And let me add that I found debugging Autobahn frustrating because it
> doesn't bubble up exceptions anywhere obvious, but I worked around that

If a promise rejects, and there is no reject handler, whenjs will
silently swallow the exception.

If you use jQuery Deferreds, the default action of jQuery Deferreds will
transform such a rejected promise (lacking a reject handler) into a
top-level exception, throw that, and this will get logged in console.

Whenjs has "monitors" for doing similar:

https://github.com/cujojs/when/blob/master/docs/api.md#whenmonitor

/Tobias
Reply all
Reply to author
Forward
0 new messages