Skip to content
This repository has been archived by the owner on Dec 18, 2018. It is now read-only.

HubProxy.Subscribe is not thread safe #70

Closed
MansVestin opened this issue Dec 10, 2016 · 1 comment
Closed

HubProxy.Subscribe is not thread safe #70

MansVestin opened this issue Dec 10, 2016 · 1 comment

Comments

@MansVestin
Copy link

Expected behavior

HubProxt.Subscribe(eventName) should be thread safe, according to documentation here:
https://www.asp.net/signalr/overview/guide-to-the-api/hubs-api-guide-net-client
And here:
http://stackoverflow.com/questions/16089876/signalr-hubproxy-invoke-thread-safety

(However, it's stated to be non-thread safe here:
https://msdn.microsoft.com/en-us/library/microsoft.aspnet.signalr.client.hubs.hubproxy(v=vs.111).aspx)

Actual behavior

HubProxy.Subscribe() accesses the _subscriptions list in a non-thread safe manner. This causes data to be sent to the wrong onData callback.

Steps to reproduce

If you call IHubProxy.On(eventName, onData) (which in turn calls HubProxy.Subscribe) lots of times from different threads at the same time, data from one event may be delivered to another onData callback.
Adding a lock around the On() call prevents the issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants