SockJS example works only with xhr-polling

2,547 views
Skip to first unread message

Ruslan Stelmachenko

unread,
Jun 20, 2014, 2:55:24 AM6/20/14
to ve...@googlegroups.com

I run example from https://github.com/vert-x/vertx-examples/blob/master/src/raw/java/sockjs/SockJSExample.java on Windows 7 x64, vert.x 2.1.1, jdk8 x64.
It works but only with xhr-polling transport.
I tried it in Chrome35, Firefox24 and IE11 with same result.
I enabled debug in SockJS and here is my js console output:
Opening transport: websocket  url:http://localhost:8080/testapp/693/gtiaqpis  RTO:417 sockjs-0.3.4.js:282
Closed transport: websocket SimpleEvent(type=close, code=2007, reason=Transport timeouted, wasClean=false) sockjs-0.3.4.js:282
Opening transport: xhr-streaming  url:http://localhost:8080/testapp/693/48dzyvom  RTO:417 sockjs-0.3.4.js:282
Closed transport: xhr-streaming SimpleEvent(type=close, code=2007, reason=Transport timeouted, wasClean=false) sockjs-0.3.4.js:282
Opening transport: xhr-polling  url:http://localhost:8080/testapp/693/1xnk76tv  RTO:417 sockjs-0.3.4.js:282
open

In network monitor i see request to http://localhost:8080/testapp/info and here is response:
{"websocket":true,"cookie_needed":true,"origins":["*:*"],"entropy":1555327858}

Then I see request to ws://localhost:8080/testapp/693/gtiaqpis/websocket with status "101 Switching protocols" but closed after 845ms. Then another request to http://localhost:8080/testapp/693/48dzyvom/xhr_streaming with status "(canceled)" after 832ms.
Then series of success requests to http://localhost:8080/testapp/693/1xnk76tv/xhr (long-polling).

My question is why WebSocket transport doesn't work?
I tried to whitelist only "websocket" transport through "protocols_whitelist" in SockJS client but result is the same (connection doesn't work at all as no backup transports allowed).

Руслан Стельмаченко

unread,
Jun 20, 2014, 3:03:56 AM6/20/14
to ve...@googlegroups.com
Now I tied all SockJS protocols: ['websocket', 'xdr-streaming', 'xhr-streaming', 'iframe-eventsource', 'iframe-htmlfile', 'xdr-polling', 'xhr-polling', 'iframe-xhr-polling', 'jsonp-polling'].
Only last 3 works (
'xhr-polling', 'iframe-xhr-polling', 'jsonp-polling').


--
You received this message because you are subscribed to a topic in the Google Groups "vert.x" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vertx/odf9qa9fzck/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vertx+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tim Fox

unread,
Jun 20, 2014, 3:29:12 AM6/20/14
to ve...@googlegroups.com
Can you add a BZ with instructions on how to replicate?
--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.

Ruslan Stelmachenko

unread,
Jun 20, 2014, 3:45:17 AM6/20/14
to ve...@googlegroups.com
Sorry, I dont know what is BZ.
But there are no any special instructions.
I just download latest vert.x for windows, added it's bin to PATH variable, download vertx-examples from github as zip, unpack it to d:\tmp\vertx\vertx-examples-master then cd to d:\tmp\vertx\vertx-examples-master\src\raw\java and run the command vertx run sockjs/SockJSExample.java.

After that i open Chrome (version 35.0.1916.153 m), press F12 to open chrome developer tools and go to Network tab then go to http://localhost:8080/ URL.

That is all. Just example from github. No changes at all.
After that i added "debug" parameter to index.html that creates SockJS instance
var sock = new SockJS('http://localhost:8080/testapp', null, { debug: true });
and try again.
Now i see debug output from SockJS in Chrome console that i linked in first post.

пятница, 20 июня 2014 г., 10:29:12 UTC+3 пользователь Tim Fox написал:

Nick Scavelli

unread,
Jun 20, 2014, 10:45:30 AM6/20/14
to ve...@googlegroups.com
BZ stands for bugzilla our bug tracking tool https://bugs.eclipse.org/bugs/describecomponents.cgi?product=Vertx). I just tested and it works with webosckets on Windows 7 x64, jdk1.8.0_05, vertx-2.1.1, Chrome 35.0.1916.153 m. Looks like same exact setup...

Руслан Стельмаченко

unread,
Jun 20, 2014, 11:10:38 AM6/20/14
to ve...@googlegroups.com
Hmm.. It's strange.
For me it doesn't work in any browser so let's assume that problem not on client side.
My jdk version is:
D:\tmp\vertx\vertx-examples-master\src\raw\java>java -version
java version "1.8.0"
Java(TM) SE Runtime Environment (build 1.8.0-b132)
Java HotSpot(TM) 64-Bit Server VM (build 25.0-b70, mixed mode)

I will try to update it and check if it fix the problem.

--
You received this message because you are subscribed to a topic in the Google Groups "vert.x" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vertx/odf9qa9fzck/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vertx+un...@googlegroups.com.

Tim Fox

unread,
Jun 20, 2014, 11:12:40 AM6/20/14
to ve...@googlegroups.com
Maybe some kind of proxy or firewall issue?

Руслан Стельмаченко

unread,
Jun 20, 2014, 12:12:50 PM6/20/14
to ve...@googlegroups.com
I updated jdk to build 1.8.0_05-b13 and tried again. No results.
I tried to disable windows firewall.
Tried sockjs example from javascript folder.
Tried to clear all cookies.
Tried to run vertx in cmd from admin.
First time when i open http://localhost:8080/ with vertx running as Administrator magically second transport (xhr-streaming) worked! Websocket still doesn't. But after I press F5 all broken again. :) I tried F5 many times but can't catch working xhr-streaming again. Then I install vert.x (same version) on my second Ubuntu 12.04 x64 machine with jdk8.
And here all working fine.

Then I disable my Kaspersky Antivirus on Windows machine and all working fine!
Can't imagine that antivirus (not firewall) can broke things like that.
Especially that i tried to connect to same sockjs Verticle with Websocket manually from JS Websocket API with success.

I'll investigate the problem and write solution (without disable antivirus) for future people that can face similar problem.

Thanks for help and sorry for your time. It's not vert.x fault!

Руслан Стельмаченко

unread,
Jun 20, 2014, 12:44:08 PM6/20/14
to ve...@googlegroups.com
The only way I can fix the problem is to fully disable Kaspersky Antivirus Web Monitor module. It have filters by URL but not by IP.
This module proxies all traffic for watch malicious javascript etc. Don't know why it broking SockJS's transports. Native JS Websocket connections works fine even with enabled module.

Nick Scavelli

unread,
Jun 20, 2014, 3:53:33 PM6/20/14
to ve...@googlegroups.com
Hmm, so native websockets work fine ? You are able to connect and send data back and forth (same host and port) ?

Nick Scavelli

unread,
Jun 20, 2014, 3:55:51 PM6/20/14
to ve...@googlegroups.com
Maybe try running it on their sockjs server (https://github.com/sockjs/sockjs-node) and see if you get the same behavior.


On Friday, June 20, 2014 12:44:08 PM UTC-4, Ruslan Stelmachenko wrote:

Руслан Стельмаченко

unread,
Jun 20, 2014, 4:05:08 PM6/20/14
to ve...@googlegroups.com
Yes. Native WebSockets works fine even when i open WS connection to same Verticle instance (sockjs\SockJSExample.java) to which I can't connect through sockjs.
And another example (vertx-examples-master\src\raw\java\websockets\WebsocketsExample.java) working fine too.

I'll try native sockjs server. But i haven't expiriense with node.js and need some investigations to install and run it. I'll report the result.

Руслан Стельмаченко

unread,
Jun 20, 2014, 5:14:04 PM6/20/14
to ve...@googlegroups.com
I tried native sockjs server with same result. Sockjs client can't connect through Websocket if antivirus web-monitor module is ON. And it can connect if web-monitor is OFF.
At least in FF.
In Chrome even official examples from sockjs can't connect through Websocket (no matter if antivirus on or off) to node.js's sockjs with error: "WebSocket connection to 'ws://localhost:9999/echo/053/q5xbe4_q/websocket' failed: WebSocket is closed before the connection is established. ". But this is out of the scope of this thread.

Finally we figure out that problem is in scope of sockjs itself (or sockjs + antivirus interaction). But not in vert.x at all.

Alexander Lehmann

unread,
Jun 20, 2014, 6:16:41 PM6/20/14
to ve...@googlegroups.com
If the thing is not working with Antivirus enabled, this may be either that the software implements a proxy that doesn't support some websocket connections or that the software is applying some kind of lookahead operation to be able to analyze javascript on the page that breaks loading of the page
(the portal I work for has a chat application that doesn't work when the virus scanner is buffering the html page to check the javascript, but works when the Web antivirus is disabled).

There also may be some kind of difference in the handling of open connections that breaks the antivirus checker when using a specific access method (this may not be an issue related to vert.x though).

Maybe you can do the following thing, first of all, check what the browser is accessing with Firebug and see if any requests hang or are denied (this would point to a proxy type issue) and please check any other sockjs application that is not using vert.x if that is working.

Nick Scavelli

unread,
Jun 23, 2014, 8:16:47 AM6/23/14
to ve...@googlegroups.com


On Friday, June 20, 2014 5:14:04 PM UTC-4, Ruslan Stelmachenko wrote:
I tried native sockjs server with same result. Sockjs client can't connect through Websocket if antivirus web-monitor module is ON. And it can connect if web-monitor is OFF.
At least in FF.
In Chrome even official examples from sockjs can't connect through Websocket (no matter if antivirus on or off) to node.js's sockjs with error: "WebSocket connection to 'ws://localhost:9999/echo/053/q5xbe4_q/websocket' failed: WebSocket is closed before the connection is established. ". But this is out of the scope of this thread.

Finally we figure out that problem is in scope of sockjs itself (or sockjs + antivirus interaction). But not in vert.x at all.

Ok good to know. Thanks for verifying ! Maybe you could try and post on sockjs ML https://groups.google.com/forum/#!forum/sockjs and see if they have any ideas.
Reply all
Reply to author
Forward
0 new messages