您是否曾经在使用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`?发布于 2019-06-18 23:17:09
消除错误的一种方法是:
let socket = io.connect(SOCKET_URL, {
timeout: 10000,
jsonp: false,
transports: [‘websocket’],
autoConnect: false,
agent: ‘-’,
path: ‘/’, // Whatever your path is
pfx: ‘-’,
key: token, // Using token-based auth.
passphrase: cookie, // Using cookie auth.
cert: ‘-’,
ca: ‘-’,
ciphers: ‘-’,
rejectUnauthorized: ‘-’,
perMessageDeflate: ‘-’
});发布于 2018-12-07 00:37:50
是的,这发生在Socket.io的WebSocket类构造函数中。我认为当你在构造函数中指定你的传输层为'websocket‘时(这是使用React Native socket io所必需的),就会发生这种情况。它不会做任何坏事,但很烦人。您可以使用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`?'
]);https://stackoverflow.com/questions/53638667
复制相似问题