连接到服务器时,我一直无法启动传输 'WebSockets': null。
我正在 reactnative 移动应用程序中实现一个简单的聊天。我正在使用 @aspnet/signalr(version-1.1.4) 库。我收到此错误 - 错误:无法启动传输“WebSockets”:空。 在此处查看日志

componentDidMount(){
try {
const connection = new signalR.HubConnectionBuilder() //Connect to a hub
.withUrl(baseUrl + `/chatbus`, {
transport: signalR.HttpTransportType.WebSockets | signalR.HttpTransportType.LongPolling,
'content-type': 'application/json',
accessTokenFactory: () => authToken //for authorization
})
.configureLogging(signalR.LogLevel.Debug)
.build();
connection.on('NotifySignalR', (ChatObject) => {
console.log(ChatObject);
});
connection.start()
.then(() => {
console.log('Chat Connection started.');
console.log('Now connected, connection ID=' + connection.id);
this.initalAttemptForChat = true;
connection.invoke("start");
})
.catch(() => {
this.initalAttemptForChat = false;
console.log('Error while establishing chatbus connection!');
});
} catch …Run Code Online (Sandbox Code Playgroud) 我试过这个解决方案,但它没有按我预期的那样工作。
这是我的代码,这是我尝试过的。
PopupMenu popup = new PopupMenu(TableActivity.this, view);
popup.setOnMenuItemClickListener(TableActivity.this);
menu = popup.getMenu();
popup.inflate(R.menu.popup_shift);
popup.show();
popup.setOnMenuItemClickListener(this);
@Override
public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_merge:
if(tableDbList.get(positionShift).getMergeTableId()== 0) {
//this is the condition to show/hide popup menuitem
popup.getMenu().findItem(R.id.menu_merge).setVisible(false);
}else {
checkPinCode.checkPinCodemethod(TableActivity.this, "mergeCancel");
}
}
return true;
}
Run Code Online (Sandbox Code Playgroud)