React native and socket.io node not working

后端 未结 4 1167
一向
一向 2021-02-18 21:34

Below is my react native component and node server.js code that I am trying to connect to my node websocket backend.

My react code is running on the same computer as th

4条回答
  •  太阳男子
    2021-02-18 22:35

    Thanks, Peter. In my opinion, the article you have found isn't helpful because you are trying to connect to the host that serves the page. According to the example on socket.io page, try to make sure that this line works: const io = require('socket.io-client/socket.io'); and connect without link: let socket = io();

    It worked for me, but only in the browser on the same computer. I think when you will test on the device you have to specify your IP instead of localhost.

    Good luck :)

提交回复
热议问题