WebSockets connection lost issue

#1

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?

0 Likes

#2

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

···

On Monday, February 24, 2014 4:27:42 AM UTC-5, DHRUPAL PATEL wrote:

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?

0 Likes

#3

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:

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

On Monday, February 24, 2014 4:27:42 AM UTC-5, DHRUPAL PATEL wrote:

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?

--
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.

0 Likes

#4

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

···

Am 24.02.2014 17:56, schrieb Nick Guenther:

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:

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

On Monday, February 24, 2014 4:27:42 AM UTC-5, DHRUPAL PATEL wrote:

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?

--
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.

0 Likes