重新连接websocket后未调用websocket事件侦听器

时间:2019-06-24 08:11:48

标签: react-native websocket react-native-android

im尝试在onerror或onclose之后在本机响应中建立持久的websocket连接。不会出现onmessage,onerror或onclose事件。在关闭连接之前,它工作正常

var  socket  =  new WebSocket('url');

socket.send ('msg')

socket.onmessage = ({ data }) => {
    process the message

}

socket.onerror = () => {
    var  socket  =  new WebSocket('url');

}

socket.onclose = () => {
    var  socket  =  new WebSocket('url');

}

0 个答案:

没有答案