ASP.NET CORE 2.1 Server timeout while debugging

前端 未结 2 1535
[愿得一人]
[愿得一人] 2021-02-20 03:15

\'Error: Server timeout elapsed without receiving a message from the server.\'.

I\'m trying to debug some server-side code and while I do

相关标签:
2条回答
  • 2021-02-20 03:22

    Thanks to @Arhire Ionut

    Here is how to increase Javascript client timeout

    hubConnection.serverTimeoutInMilliseconds = 100000; // 100 second
    

    More details here => https://github.com/aspnet/Docs/issues/6885

    0 讨论(0)
  • 2021-02-20 03:43

    What @MahmoudFarhat mentioned in another answer is correct. But also take a look at this link and then read my comments below.

    If signalR got disconnected, you should try re-establishing the connection again. The connection could drop for several other reasons, including the user switching networks. For example if the user is using a cell-phone and connected to the home/office Wifi but steps out which then connects to cellular data connection.

    To reconnect you could use the following (works like a charm for me):

    // re-establish the connection if connection dropped
    connection.onclose(() => setTimeout(startSignalRConnection(connection), 5000));
    

    where startSignalRConnection is :

    const startSignalRConnection = connection => connection.start()
      .then(() => console.info('Websocket Connection Established'))
      .catch(err => console.error('SignalR Connection Error: ', err));
    

    and connection is

    const connection = new HubConnectionBuilder()
      .withUrl(connectionHub, options)
      .withHubProtocol(protocol)
      .build();
    
    0 讨论(0)
提交回复
热议问题