dsuryd / dotNetify

Simple, lightweight, yet powerful way to build real-time web apps.
https://dotnetify.net
Other
1.17k stars 164 forks source link

Is there a way to set the serverTimeoutInMillseconds setting? #324

Closed brianpricesmith closed 10 months ago

brianpricesmith commented 10 months ago

I have a VM that in some cases can take longer than the default 30 seconds to load. It looks like the setting for this is on the @microsoft/signalr hub connection class. It’s called serverTimeoutInMilliseconds. Is there a way to access this through dotnetify? I tried using the hubOptions connection builder and was not successful. Thanks!

dsuryd commented 10 months ago

You can access the HubConnection object and change that property through dotnetify.hub._connection.

brianpricesmith commented 10 months ago

Awesome thank you. With typescript I was able to do what I needed by extending the IDotnetifyHub interface, then accessing the property you described. Example code below:

import { IDotnetifyHub } from 'dotnetify';
import { HubConnection } from '@microsoft/signalr';

export interface IDotnetifyHubConnection extends IDotnetifyHub {
  _connection: HubConnection
}
  const dotnetifyHub = dotnetify.hub as IDotnetifyHubConnection;
  if(dotnetifyHub?._connection && dotnetifyHub._connection.serverTimeoutInMilliseconds !== 60000){
    dotnetifyHub._connection.keepAliveIntervalInMilliseconds = 30000;
    dotnetifyHub._connection.serverTimeoutInMilliseconds = 60000;
  }