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
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...
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.
They said Opera WebSocket is implemented on hixie-76/hybi-00 specification.
Maybe this is a problem.
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?
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.
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
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.
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?
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.
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)\
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.
This topic is now closed. New replies are no longer allowed.