ketting00 — 2012-05-18T03:27:46-04:00 — #1
I've followed this guideline [http://my.opera.com/core/blog/websockets] to connect to server via WebSocket with Opera but it always says WebSocket closed :-(.
The server is build on Node.js and I have no problem connected to it with Google Chrome and Firefox.
I've tried to enable WebSocket on Opera and it said nothing saved.
Anyone have an idea how I can overcome this issue or do I miss something.
Thanks so much
omgcarlos — 2012-05-18T11:21:12-04:00 — #2
In the onclose and onmessage event, add this line of code:
and copy paste the exact message here. It could be a number of things...
ketting00 — 2012-05-18T21:57:14-04:00 — #3
Thank you so much for response.
Here's the messages:
Receive request for / test/index.php
Receive request for / favicon.ico
I only got it done for only one time and it just not happened again.
And noted that it's just a plain test page. I didn't link to stylesheet or favicon.ico.
ketting00 — 2012-05-19T05:38:54-04:00 — #4
They said Opera WebSocket is implemented on hixie-76/hybi-00 specification.
Maybe this is a problem.
aufshebung — 2012-05-19T22:50:20-04:00 — #5
As far as I can tell, you're right. Opera 11 still implements an obsolete version of the WebSockets protocol, and that's causing the problem.
How did you install WebSockets on your Node server? If you went the "npm install websocket" route, then you ended up with the WebSocket-Node project. It does not support browsers that have older implementations of the protocol:
I made a decision early on to explicitly avoid maintaining multiple slightly different copies of the same code just to support the browsers currently in the wild. The major browsers that support WebSocket are on a rapid-release schedule (with the exception of Safari) and now that the final version of the protocol has been published as an official RFC, it won't be long before support in the wild stabilizes on that version.
It does link to a workaround for older browsers, but the fix seemed kind of convoluted to me. How important is it that you support Opera?
ketting00 — 2012-05-20T00:51:46-04:00 — #6
Thanks for additional information.
Yes, I installed WebSocket with npm.
My app is building around Opera, Opera Mobile, to be exact, because it eliminates the hassles for my users to configure their browsers in order to use the app.
I assume that most not-so-techie users do not know how to do this e.g. with Chrome or Safari.
Opera Mobile makes it easy just as install and shoot.
But there's a problem as I mentioned above.
aufshebung — 2012-05-20T05:39:15-04:00 — #7
I'm unable to test Opera Mobile, but I was able to get it working in Opera/Win7, for what it's worth.
I wish I could be more help, because the workaround code is pretty convoluted, but it all depends on what you're trying to do; I was just testing basic WebSockets support, so I only had to set up a bare-bones server that echoed back any messages it received.
If you have difficulty with it, don't be afraid to ask for more help
ketting00 — 2012-05-20T08:50:18-04:00 — #8
That's very kind of you.
Yes, I'm currently testing it on Opera 11 / Win 7 environment. And I want to make my app usable on all kind of devices (PC, tablet, smartphone etc.).
I've tried to overcome this problem more than a month now and feel kinda of giving up.
I'm more than appreciated if you could help me.
There's no already solution on the internet, according to my research, well, I don't know.
It would be great if you post solution here as I see more people trying to do this as well.
aufshebung — 2012-05-21T14:39:39-04:00 — #9
What part of the workaround are you having trouble with?
Here are a couple of points that tripped me up along the way:
- Make sure you have websocket-server installed. Just like you did "npm install websocket", you'll have to do "npm install websocket-server" as well.
- Make sure you have the path to websocket-server right. At one point in the workaround, you need to do "require('./node_modules/websocket-server/lib/ws/connection')". That path assumes that your server script is running in the "nodejs" folder. Is that true?
ketting00 — 2012-05-21T20:05:12-04:00 — #10
The part I've troubled with is "require('./node_modules/websocket-server/lib/ws/connection')".
It said cannot find module (around that, I can't remember). The "/ws/connection" wasn't there.
I'll check it again.
aufshebung — 2012-05-21T20:14:14-04:00 — #11
The './node_modules/websocket-server/lib/ws/connection' is a path; if you open your "nodejs" folder, there should be a subfolder called "node_modules". Inside that should be a "websocket-server" folder, and so on and so forth.
If you did "npm install websocket-server" and there were no errors, but you still didn't get the "ws" subfolder, then something has gone seriously wrong.
Can you verify that there is a file called "connection.js" in "node_modules/websocket-server/lib/ws"?
My guess is that your server is saved in a subfolder of its own, rather than right under "nodejs" (which is what the workaround assumes). My own server was saved in a folder called "websocket_test", so I had to change the one dot ("./") to a two dot ("../").
What's the full path to your server? Here's mine, so you'll have it for comparison:
C:\\Program Files (x86)\
ketting00 — 2012-05-21T21:15:05-04:00 — #12
I'll check it again. I'm not with the computer I tested it now. I've followed this tutorial: http://cjihrig.com/blog/creating-your-own-node-js-websocket-echo-server/
Maybe something went missing.