I have to send messages to my signalr hubs from my windows services. Some of my windows services run on .net framework 3.5. My first step was adding this package:
https://www.nuget.org/packages/Nivot.SignalR.Client.Net35/
Here is my whole test code for this scenario:
public partial class WinSer35 : ServiceBase
{
private HubConnection hubConnection;
private IHubProxy priceProxy;
public WinSer35()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
hubConnection = new HubConnection("http://localhost:8080/signalr", useDefaultUrl: false);
priceProxy = hubConnection.CreateHubProxy("PriceHub");
hubConnection.Start().Wait();
TestPrice testPrice = new TestPrice() { Id = 1, Buy = 1.2345, Sell = 9.8765, Symbol = "EURUSD" };
priceProxy.Invoke("NotifySubscribers", testPrice).Wait();
}
protected override void OnStop()
{
}
}
On line:
hubConnection.Start().Wait();
I'm getting the following exception:
Service cannot be started. System.AggregateException: AggregateException_ctor_DefaultMessage ---> System.Net.WebException: The remote server returned an error: (400) Bad Request. at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult) at Microsoft.AspNet.SignalR.Client.Http.HttpHelper.<>c__DisplayClass2.b__0(IAsyncResult ar) at System.Threading.Tasks.TaskFactory
1.FromAsyncCoreLogic(IAsyncResult iar, Func
2 endMethod, TaskCompletionSource`1 tcs) --- End of inner exception stack trace --- at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken) at System.Threading.Tasks.Task.Wait() at WinSer35.WinSer35.OnStart(String[] args) in c:\\Users\\anilcaliskan\\Desktop\\WindowsFormsApplication1\\WinSer35\\WinSer35.cs:line 28 at System.ServiceProcess.ServiceBase.ServiceQueuedMainCallback(Object state) ---> (Inner Exception #0) System.Net.WebException: The remote server returned an error: (400) Bad Request. at System.Net.HttpWebRequest....
Same code piece running on .net framework 4.5 and referenced the default Microsoft.AspNet.SignalR.Client dll works as expected.
Do you have any suggestions? Think of I have a few other dependencies and I can not compile my windows services in a version greater than .net framework 3.5.
如果它确实是一个3.5库,它甚至不应该包含那些方法,因为那是4.5代码
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.