Closed akousmata closed 6 years ago
This is fixed in the 1.1.0 preview builds, you can try them out, or if that isn't possible add a small delay between start
and invoke
.
When do you anticipate releasing 1.1.0?
Soon is all I can say, https://github.com/aspnet/AspNetCore/wiki/Roadmap#schedule
so the fix is in the server side code?
No, it's on the client side. It wasn't waiting for the handshake response before returning from start.
I see, but you're going to time the release with .Net Core 2.2.
Looking at the above code though there's a bug where you're invoking after calling start without waiting on start to complete.
transactionConnection.start().catch(err => console.error(err.toString()));
transactionConnection.invoke('JoinGroup', 'ClientAccountTransaction').catch(err => console.error(err.toString()));
This is incorrect, it should be:
transactionConnection.start().then(() => {
transactionConnection.invoke('JoinGroup', 'ClientAccountTransaction').catch(err => console.error(err.toString()));
});
@BrennanConroy David's answer worked on my end.
Yeah, I missed that you weren't waiting for start to finish. Although you might see the issue occasionally still because of the bug I was referring to.
Doing a really simple call from the client to the server following this article's example. When I originally set it up, I had the following code:
If I launch the page this way, I get the error in the title (client debug is attached). signalrdebug.txt
It seemed like based on the order of the log messages, that the connection needed time to get established, so I added a button to the page with an on click event that calls:
transactionConnection.invoke('JoinGroup', 'ClientAccountTransaction').catch(err => console.error(err.toString()));
And that worked. Unfortunately, there's no way I can present that to the client, this is all supposed to work under the hood. Is my assumption correct about the timing of the calls and if so what do you recommend we do to work around this?