Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use ASP.NET Core SignalR with Pace.js

I have an ASP.NET Core 2.2 MVC project that has HTTPS enabled and targets Docker Linux containers. I have followed all the instructions at https://learn.microsoft.com/en-us/aspnet/core/tutorials/signalr?view=aspnetcore-2.2&tabs=visual-studio to enable SignalR in my project.

When the project is run I see the following SignalR-related log entries:

[2019-02-19T15:20:14.395Z] Information: Normalizing '/mainHub' to 'https://localhost:44392/mainHub'. Utils.ts:185:30

[2019-02-19T15:20:14.858Z] Information: WebSocket connected to wss://localhost:44392/mainHub?id=3RS_UsO7L20SQHgW4meRpQ. Utils.ts:185:30

WebSocket is not in the OPEN state insys-signalr-location.min.js:1:426

[2019-02-19T15:33:41.840Z] Error: Connection disconnected with error 'Error: WebSocket closed with status code: 1006 ().'. Utils.ts:179:21

Error: WebSocket closed with status code: 1006 (). WebSocketTransport.ts:130:16

Is there anything in particular I need to do to use SignalR with pace.js?

EDIT

Initially I thought this was a problem with Docker. After identifying the conflict with pace.js I reframed the question.

like image 449
ProfNimrod Avatar asked Oct 28 '25 14:10

ProfNimrod


1 Answers

Turns out that this was a conflict with pace.js. Running the following script before loading pace.js solved the problem:

<script>
    window.paceOptions = { ajax: { ignoreURLs: ['mainHub', '__browserLink', 'browserLinkSignalR'], trackWebSockets: false } }
</script>
like image 157
ProfNimrod Avatar answered Oct 31 '25 04:10

ProfNimrod



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!