Note that there are some explanatory texts on larger screens.

plurals
  1. POSocket.io fails to emit messages to Node server on Chrome & Firefox
    primarykey
    data
    text
    <p>I'm trying to figure out what is wrong with my code / settings for a while now.Basically I want to send a message from the client to the server. The following works in all browsers <strong>except</strong> FF(11) and chrome(18.0.1025.152 m).</p> <p>Here is some info:</p> <ol> <li>I run Node.js on Windows 7 enterprise 64-bit machine</li> <li>I use apache to serve the page from localhost</li> <li>I'm listening on port 8080 with socket.io</li> <li>It looks like chrome and FF fallback to xhr-polling / jsonp-polling instead of using sockets</li> <li>I can push messages from the server, but I can't emit from the client</li> </ol> <p>Server code:</p> <pre><code>var io = require('C:/Users/shlomis/node_modules/socket.io/lib/socket.io').listen(8080); io.sockets.on('connection', function (socket) { socket.on('my event', function (msg) { console.log("DATA!!!"); }); }); </code></pre> <p><strong>I could not find a way to require without a full path</strong></p> <p>Client code:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;title&gt;Hello World!&lt;/title&gt; &lt;meta charset="utf-8"&gt; &lt;script src="http://localhost:8080/socket.io/socket.io.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function(){ var socket = io.connect('http://localhost:8080'); $("#button").click(function() { socket.emit('my event' ,"Hello World!"); }) }) &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;button type="button" id='button'&gt;Send Message&lt;/button&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Modules versions:</p> <pre><code>C:\Users\shlomis&gt;npm ls mukhin_chat@0.0.1 C:\Users\shlomis ├─┬ express@2.5.9 │ ├─┬ connect@1.8.6 │ │ └── formidable@1.0.9 │ ├── mime@1.2.4 │ ├── mkdirp@0.3.0 │ └── qs@0.4.2 └─┬ socket.io@0.9.5 ├── policyfile@0.0.4 ├── redis@0.6.7 └─┬ socket.io-client@0.9.5 ├─┬ active-x-obfuscator@0.0.1 │ └── zeparser@0.0.5 ├── uglify-js@1.2.5 ├─┬ ws@0.4.12 │ ├── commander@0.5.2 │ └── options@0.0.3 └── xmlhttprequest@1.2.2 </code></pre> <p>Node log:</p> <pre><code>C:\Users\shlomis&gt;node C:\dev\wamp\www\AR\js\videoServer.js info - socket.io started debug - served static content /socket.io.js debug - client authorized info - handshake authorized 17502185141066845391 debug - setting request GET /socket.io/1/websocket/17502185141066845391 debug - set heartbeat interval for client 17502185141066845391 debug - client authorized for debug - websocket writing 1:: debug - setting request GET /socket.io/1/xhr-polling/17502185141066845391?t=1334041653716 debug - setting poll timeout debug - discarding transport debug - cleared heartbeat interval for client 17502185141066845391 </code></pre> <p>chrome WS request (101 Switching Protocols): <img src="https://i.stack.imgur.com/w3pyK.gif" alt="enter image description here"></p> <p>chrome XHR request: <img src="https://i.stack.imgur.com/N6O9f.gif" alt="enter image description here"></p> <p><strong>Update :</strong> Iv'e added</p> <pre><code>socket.on('connect', function () { console.log("connected"); }); </code></pre> <p>It never fires on chrome.</p> <p>So what could be wrong? please help out :)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload