Pages

Tuesday, August 28, 2018

How to test locally SignalR on ASP.NET Core app with different connection issues

For example, I used an app with SignalR on ASP.NET Core.

How to limit speed between localhost apps using NetLimiter4

Can be downloaded at https://www.netlimiter.com/

  1. Run application using Visual Studio and select Google Chrome (or your other browsers) in NetLimiter

  2. Right-click to Selected row and choose connection speed you want to select. Then enable incoming/outgoing limit rule by selection checkbox on the selected row
My tests for SignalR apps showed, that WebSocket connection works perfect on 5KB/s speed. It even worked for me on very slow speed (0.5KB/sec) with some delay.
To view WebSocket frames use Developers tools from Google Chrome (F12 key), select Network tab, and filter by WS filter.


How to test network disconnection between machines:
You can use a virtual machine to test this case. I prefer using Hyper-V built-in in Windows 10 (available from Windows professional and upper).
  1. Hyper-V setup documentation: https://docs.microsoft.com/en-us/virtualization/hyper-v-on-windows/quick-start/enable-hyper-v
  2. install Windows (or other OS) from OS image via Hyper-V, manager.
  3. Run your app from host machine with dotnet run --urls http://0.0.0.0:5000 to allow Kestrel external connections
  4. Setup Windows firewall to allow external connections netsh advfirewall firewall add rule name="Http Port 5000" dir=in action=allow protocol=TCP localport=5000
  5. Run browser in you virtual machine browser and connect to you host machine by IP and specified port (5000 in my example)

No comments:

Post a Comment