1
我們的反應原生應用程序有時會連接到我們的websocket(我們正在使用sockjs)。發生這種情況時,它會阻止所有網絡請求,從本質上阻止我們的應用程序運行react-native websocket ERR_NAME_NOT_RESOLVED停止網絡請求
當它發生時,控制檯不停止記錄:
GET http://192.168.0.11.xip.io:8080/sock/194/noeli4ep/eventsource
net::ERR_NAME_NOT_RESOLVED
這是我們的連接腳本,應用程序啓動時運行,它也運行在插座關閉(這是爲了讓重新連接到插座)。
connectToServer() {
if (!this.flagConnect) {
this.webSocket = new SockJS(`${config.endpoint}sock`);
this.webSocket.onopen = this.onOpen; // Just sets this.opened to true
this.webSocket.onmessage = this.onMesssage; // Just reads the msgs
this.webSocket.onclose = this.onClose; // Re-calls connectToServer()
this.webSocket.onerror = this.onError; // Console.logs the error
}
}
我們使用使用上的應用程序&後端(的NodeJS)sockJS陣營本地0.41 &。