L.G*_*L.G 16 websocket react-native
您是否曾使用WebSocket(来自'socket.io-client'的SocketIOClient)在React Native应用程序中遇到此消息?...
Unrecognized WebSocket connection option(s) `agent`, `perMessageDeflate`, `pfx`, `key`, `passphrase`, `cert`, `ca`, `ciphers`, `rejectUnauthorized`. Did you mean to put these under `headers`?
Run Code Online (Sandbox Code Playgroud)
Dav*_*ing 32
是的,这发生在Socket.io中的WebSocket类构造函数中.我认为在构造函数中将传输层指定为'websocket'时会发生这种情况(这对于使用React Native套接字是必需的).它没有做任何坏事,但很烦人.您可以使用react-native去除它YellowBox.ignoreWarnings:在启动您的应用时:
console.ignoredYellowBox = ['Remote debugger'];
import { YellowBox } from 'react-native';
YellowBox.ignoreWarnings([
'Unrecognized WebSocket connection option(s) `agent`, `perMessageDeflate`, `pfx`, `key`, `passphrase`, `cert`, `ca`, `ciphers`, `rejectUnauthorized`. Did you mean to put these under `headers`?'
]);
Run Code Online (Sandbox Code Playgroud)
消除错误的一种方法:
\n\nlet socket = io.connect(SOCKET_URL, {\n timeout: 10000,\n jsonp: false,\n transports: [\xe2\x80\x98websocket\xe2\x80\x99],\n autoConnect: false,\n agent: \xe2\x80\x98-\xe2\x80\x99,\n path: \xe2\x80\x98/\xe2\x80\x99, // Whatever your path is\n pfx: \xe2\x80\x98-\xe2\x80\x99,\n key: token, // Using token-based auth.\n passphrase: cookie, // Using cookie auth.\n cert: \xe2\x80\x98-\xe2\x80\x99,\n ca: \xe2\x80\x98-\xe2\x80\x99,\n ciphers: \xe2\x80\x98-\xe2\x80\x99,\n rejectUnauthorized: \xe2\x80\x98-\xe2\x80\x99,\n perMessageDeflate: \xe2\x80\x98-\xe2\x80\x99\n});\nRun Code Online (Sandbox Code Playgroud)\n
| 归档时间: |
|
| 查看次数: |
7902 次 |
| 最近记录: |