WebSocket connection failed with error Error Domain=NSPOSIXErrorDomain Code=61 "Connection refused"

2020-02-16 19:16:12

我出现这个多原因,是不小心在虚拟机上跑多时候,用了localhost来访问接口。就出现了这个问题,改成ip访问就没事了。

参考地址一: 


天在用react native开发时,一开始还好好的,后来不知为啥,突然报错如下:


WebSocket connection failed with error Error Domain=NSPOSIXErrorDomain Code=61 "Connection refused"




多次重启,刷新也没用,很奇怪,经搜索,发现一篇文章:


http://www.jianshu.com/p/2c5e738cecca


解决:

在RCTWebSocketExecutor.m文件中修改setup函数中的localhost为你电脑的IP地址(例如:192.168.0.104)



但不能很肯定这么改就是正确的,毕竟我之前是可以运行的,突然不好使了,


按照上面的方法改了下,还真好了!囧。。。



  • 2017-11-01 01:30:45

    解决第三方包内jar包冲突

    这个问题就是因为引入jar包的冲突,这时我们可以在build.gradle中添加如下代码,下方单独的是添加的代码

  • 2017-11-06 01:00:17

    撤销git add

    如何撤销git add,不小心执行了git add . 操作,但是又不能提交所有的文件,因为对应不同的分支,现在怎么样可以将git add 撤销回来

  • 2017-11-10 00:06:15

    CORS: credentials mode is 'include'

    XMLHttpRequest cannot load http://localhost/Foo.API/token. The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. Origin 'http://localhost:5000' is therefore not allowed access. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.