I have two machines on the same network say at 192.168.1.2 and 192.168.1.3.
192.168.1.2 = server/dev pc
192.168.1.3 = client/browser pc
So on the server/dev pc I have a socket.io/http server running on port 82
On the client server I'm using chrome as the browser
The server is hosting a webpage like
<html>
....
<script type="text/javascript" src="http://localhost:82/socket.io/socket.io.js"></script>
....
</html>
This is a necessary resource required for the socket.io client. So the resource loads on my server/dev pc, but not on my client pc. So I try:
<html>
....
<script type="text/javascript" src="http://192.168.1.2:82/socket.io/socket.io.js"></script>
....
</html>
Now it doesn't work on either pc. I know that it should be
<script src="http://<uri:port>/socket.io/socket.io.js"></script>
as it says on the socket.io github, but I want to only test on a local network.
I've also looked at
<script type="text/javascript" src="http://cdn.socket.io/stable/socket.io.js"></script>
but I'm using socket.io 0.8.4 so the above version doesn't work.
So how can I get the socket.io resource served to the client in a local network environment? Or do you guys know of a website serving the 0.8.4 version of socket.io I could use?
Note: There are not firewall problems.
socket.io only works when connected to the internet #2309.
Although Socket.IO indeed uses WebSocket for transport when possible, it adds additional metadata to each packet. That is why a WebSocket client will not be able to successfully connect to a Socket.IO server, and a Socket.IO client will not be able to connect to a plain WebSocket server either.
In order to do it, you need to create an index. js file and install socket.io and express. You can use the following command: touch index. js && npm install express socket.io && npm install --save-dev nodemon .
It requires almost no basic prior knowledge of Node.JS or Socket.IO, so it's ideal for users of all knowledge levels.
Try letting socket.io connect automagically with
var socket = io.connect();
That worked for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With