Y
Y
Yuri Kulaxyz2020-02-04 15:39:46
Node.js
Yuri Kulaxyz, 2020-02-04 15:39:46

Why is the socket.io server not working?

I want to use Laravel in conjunction with socket.io (I use laradock).
Here is server.js code

let io = require('socket.io')(6001);

io.on('connect', function (socket) {
    console.log('hi');
});

Here is the client:
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.4.5/socket.io.min.js"></script>
<script>
    let socket = io('http://localhost:6001')
</script>

The server through node is started. Here's what happens in the console on the client:
5e3964f51edaf925687829.png
I tried to set other ports in both files and on the client options like:
let socket = io(':6001')
    let socket = io.connect('http://localhost:6001')
    let socket = io.connect(':6001')

Nothing helped. Googled, the solutions did not help.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yuri Kulaxyz, 2020-02-04
@Kulaxyz

Didn't approach the problem from the right direction. I tried without docker (I also have node.js installed locally) and everything works. Apparently the problem is still somewhere with laradock

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question