나는 SignalR 2.0.0 Win2012 iis8을 서로 다른 두 개의 ips가있는 두 개의 환경에서 사용합니다. 하나의 환경 서비스가 가동되고 두 번째로 (의도적으로) 은 웹 소켓 프로토콜을 사용합니다.SignalR 연결 오류
다음과 같은 시나리오가 있습니다. 첫 번째 환경에 연결하고 두 번째 환경에 연결할 때. 첫 번째 환경에서 연결이 끊긴 두 번째 환경에 연결하려고하면 오류가 발생합니다 (올바른 동작) 첫 번째 환경에 다시 연결하려고하지만 여전히 동일한 오류가 발생합니다.
오류는 "협상 요청 중 오류"입니다. 브라우저를 새로 고친 후 첫 번째 환경에 성공을 다시 연결할 수 있습니다.
내가 뭘 잘못하고 있니? 당신은 당신의 첫 번째 연결 참조를 유지하지 않을
function connect(host)
{
var hubConnection = $.hubConnection.('');
hubConnection.url = host;
hubConnection.start()
.done(open)
.fail(error);
}
function open()
{
console.log('login success')
}
function disconnect()
{
var self = this,
hubConnection = $.hubConnection("");
console.log('disconnect ')
hubConnection.stop(true, true);
}
function error(error)
{
var self = this,
hubConnection = $.hubConnection("");
console.log('connection error ')
if(error && hubConnection.state !== $.connection.connectionState.connected)
{
.....
.....
//logic detemninate wich environment ip was previous
connect(environment ip)
}
}
//occured when button disconnect clicked
function disconnectFromFirstEnvironmentAndConnectToSecond()
{
disconect();
connect(second environment ip);
}
.....
.....
connect(first environment ip);
우리가 도울 수 있도록 코드를 추가하십시오 –
질문에 코드를 추가했습니다. 감사합니다. – user3227750