Hey! I have a problem in a specific situation where i the server i am connecting to (that i dont have control over) sometimes shut off (or just restart). When we lose the connection, we get this error on the longpolling:
And as i see it currently, the handshake is successfully done. But since we are not also "re-" subscribing, then we dont any longer get any messages.
So if someone could please help me get an overview of how i can setup an automatic "Re-Subscribe" feature for when this happens 😓 I have sat with this problem for a very long time now
If it is any help, this is the code i am using when starting my client:
}
public Task StartAsync(CancellationToken cancellationToken)
{
StartRelatelConnection();
return Task.CompletedTask;
}
public Task StopAsync(CancellationToken cancellationToken)
{
RelatelChannel.Unsubscribe();
RelatelBayeuxClient.Disconnect();
return Task.CompletedTask;
}
private void StartRelatelConnection()
{
string relatelServer = Config.RelatelServerEndpoint;
string companyId = Config.KeyholesCompanyIdAtRelatel;
string accessToken = Config.RelatelAccessToken;
//"Options" for the longpolling transport (such as timout, interval, etc)
Dictionary<string, object> options = new Dictionary<string, object>();
//Optional HTTP headers to be sent with the longpollingtransport
NameValueCollection httpHeaders = new NameValueCollection();
LongPollingTransport clientTransport = new LongPollingTransport(options, httpHeaders);
RelatelBayeuxClient = new BayeuxClient(relatelServer, clientTransport);
//Adds access_token to outgoing meta messages, (so far only used on Subscribing)
RelatelBayeuxClient.AddExtension(new AuthTokenExtension(accessToken, _loggerService));
RelatelBayeuxClient.Handshake();
RelatelBayeuxClient.WaitFor(10000, new List<BayeuxClient.State> { BayeuxClient.State.CONNECTED });
}
Hey! I have a problem in a specific situation where i the server i am connecting to (that i dont have control over) sometimes shut off (or just restart). When we lose the connection, we get this error on the longpolling:
And as i see it currently, the handshake is successfully done. But since we are not also "re-" subscribing, then we dont any longer get any messages.
So if someone could please help me get an overview of how i can setup an automatic "Re-Subscribe" feature for when this happens 😓 I have sat with this problem for a very long time now
If it is any help, this is the code i am using when starting my client:
` public RelatelHostedService(IMessageListener messageListener, ILoggerService loggerService) { _messageListener = messageListener; _loggerService = loggerService;
}`