nicholasrobinson / node-smartcielo

NodeJs interface for interacting with smartcielo remote AC control API (MRCOOL)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Disconnects are not handled

nicholasrobinson opened this issue · comments

Disconnects result in an unresponsive interface, with no indication of issue. The code should attempt to reconnect automatically (with exponential back-off), or fail with reason.

So, this is clearly a signalR based server - is there a reason you don't just use the signalR javascript client package?
https://docs.microsoft.com/en-us/aspnet/core/signalr/javascript-client?view=aspnetcore-5.0

Besides removing most of the code you have, it also supports auto-reconnect.

@dberlin I had no idea that the signalr client was open source! I’ll keep this in mind in my next update! Eliminating the communication code would make this a lot easier!! Feel free to raise a PR!

@dberlin Quick update:

I threw together a quick test using the ASP.NET Core SignalR JavaScript Client you referenced (aka @microsoft/signalr).

I encountered the following error:

[2021-02-23T07:19:39.037Z] Error: Failed to start the connection: Error: Detected a connection attempt to an ASP.NET SignalR Server. This client only supports connecting to an ASP.NET Core SignalR Server. See https://aka.ms/signalr-core-differences for details.

Reading the referenced documentation suggests we should instead be using the ASP.NET SignalR Client (aka signalr)

I'll give that a shot and see what happens!

@dberlin Last update for the night:

Going down the rabbit hole, I quickly discovered that the ASP.NET SignalR Client (aka signalr) is NOT very nodejs friendly. It is heavily browser/jquery dependent. Probing further, I end up on StackOverflow and then at another GitHub project, which is eerily similar to the signalr client code that I have already written.

Unless you have further insights, I am thinking that simply adding reconnect logic to the existing codebase is the path of least resistant here.

Closing per #19