locked
System.InvalidOperationException: Server negotiation failed RRS feed

  • Question

  • User-125926659 posted

    I'm getting "Server negotion failed" error after calling connecting.Start() on a specific device.

    The URL where ASP.NET app hosting the SignalR hub is running can be accessed on this device.

    Running exact same code on another device, and everything works OK. So I assume it's something with this device.

    Any hints why this is not working?


    This is a Xamarin Android application and I'm using latest SignalR client by NuGet in the PCL.


    Here's the full stack-trace:

    at Microsoft.AspNet.SignalR.Client.Transports.TransportHelper+<>c.<GetNegotiationResponse>b__0_1 (System.String raw) <0x41273910 + 0x000bb> in <filename unknown>:0
    at Microsoft.AspNet.SignalR.TaskAsyncHelper+<>c__DisplayClass31_0`2[T,TResult].<Then>b__0 (System.Threading.Tasks.Task`1 t) <0x41269ff0 + 0x0005e> in <filename unknown>:0
    at Microsoft.AspNet.SignalR.TaskAsyncHelper+TaskRunners`2+<>c__DisplayClass3_0[T,TResult].<RunTask>b__0 (System.Threading.Tasks.Task`1 t) <0x41269e40 + 0x000c5> in <filename unknown>:0
    --- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0x41280eb0 + 0x0002b> in <filename unknown>:0
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) <0x41280db0 + 0x000cf> in <filename unknown>:0
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) <0x41280cf0 + 0x00097> in <filename unknown>:0
    at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) <0x411d8cb0 + 0x0003b> in <filename unknown>:0
    at System.Runtime.CompilerServices.TaskAwaiter.GetResult () <0x41280cd0 + 0x00013> in <filename unknown>:0
    at MyApp.MyService+<Connect>d__4.MoveNext () <0x41219830 + 0x0056b> in <filename unknown>:0

    Sunday, September 11, 2016 1:08 PM

All replies

  • User-125926659 posted

    Based on what I read on this line:

    https://github.com/SignalR/SignalR/blob/799d9bc32524066344cb3656e5f28f2fd03ba9b3/src/Microsoft.AspNet.SignalR.Client/Transports/TransportHelper.cs#L32

    the "negotiation" is just a HTTP request to the "negotiation" URL, which (based on my little understanding and research) is "http://mywebsite/signalr/negotiate"

    This shouldn't fail as the device has internet and if I navigate in the device web-browser (Chrome) to "http://mywebsite/signalr/negotiate" it works, so URL is accessible.

    Sunday, September 11, 2016 2:19 PM
  • User-125926659 posted

    I did more tests.

    In the mobile app, I have this:

    var x = new HttpClient();
    var r = await x.GetAsync(new Uri("http://mywebsite/signalr/negotiate"));
    var sr = await r.Content.ReadAsStringAsync();

    This throws exception:

    System.Net.WebException: Error getting response stream (chunked Read2): ReceiveFailure ---> System.Exception: at System.Net.WebConnection.HandleError (WebExceptionStatus st, System.Exception e, System.String where) [0x00000] in <filename unknown>:0 
    at System.Net.WebConnection.Read (System.Net.HttpWebRequest request, System.Byte[] buffer, Int32 offset, Int32 size) [0x00000] in <filename unknown>:0 
    at System.Net.WebConnectionStream.ReadAll () [0x00000] in <filename unknown>:0 
    at System.Net.HttpWebResponse.ReadAll () [0x00000] in <filename unknown>:0 
    at System.Net.HttpWebRequest.CheckFinalStatus (System.Net.WebAsyncResult result) [0x00000] in <filename unknown>:0 
    at System.Net.HttpWebRequest.SetResponseData (System.Net.WebConnectionData data) [0x00000] in <filename unknown>:0 
    at System.Net.WebConnection.ReadDone (IAsyncResult result) [0x00000] in <filename unknown>:0 
    at System.Net.Sockets.SocketAsyncResult+<Complete>c__AnonStorey0.<>m__0 (System.Object _) [0x00000] in <filename unknown>:0 
    at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () [0x00000] in <filename unknown>:0 
    at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00000] in <filename unknown>:0 
    at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () [0x00000] in <filename unknown>:0 
    at System.Net.WebConnection.HandleError (WebExceptionStatus st, System.Exception e, System.String where) <0x420d0240 + 0x0020f> in <filename unknown>:0 
    --- End of inner exception stack trace ---
    at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) <0x420af9f0 + 0x001c3> in <filename unknown>:0 
    at System.Threading.Tasks.TaskFactory`1[TResult].FromAsyncCoreLogic (IAsyncResult iar, System.Func`2 endFunction, System.Action`1 endAction, System.Threading.Tasks.Task`1 promise, Boolean requiresSynchronization) <0x42070090 + 0x00093> in <filename unknown>:0 
    --- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0x420d4290 + 0x0002b> in <filename unknown>:0 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) <0x420d3db0 + 0x000cf> in <filename unknown>:0 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) <0x420d3c10 + 0x00097> in <filename unknown>:0 
    at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) <0x4206cb50 + 0x0003b> in <filename unknown>:0 
    at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () <0x4206cad0 + 0x00017> in <filename unknown>:0 
    at System.Net.Http.HttpClientHandler+<SendAsync>c__async0.MoveNext () <0x41ff88c0 + 0x011bf> in <filename unknown>:0 
    --- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0x420d4290 + 0x0002b> in <filename unknown>:0 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) <0x420d3db0 + 0x000cf> in <filename unknown>:0 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) <0x420d3c10 + 0x00097> in <filename unknown>:0 
    at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) <0x4206cb50 + 0x0003b> in <filename unknown>:0 
    at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () <0x4206cad0 + 0x00017> in <filename unknown>:0 
    at System.Net.Http.HttpClient+<SendAsyncWorker>c__async0.MoveNext () <0x41ff20b0 + 0x004ab> in <filename unknown>:0 
    --- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0x420d4290 + 0x0002b> in <filename unknown>:0 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) <0x420d3db0 + 0x000cf> in <filename unknown>:0 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) <0x420d3c10 + 0x00097> in <filename unknown>:0 
    at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) <0x4206cb50 + 0x0003b> in <filename unknown>:0 
    at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () <0x420c7290 + 0x00017> in <filename unknown>:0 
    at MyApp.Droid.MainActivity+<OnCreate>d__0.MoveNext () <0x41253980 + 0x007ef> in <filename unknown>:0

    However, if I call:

    var x = new HttpClient();
    var r = await x.GetAsync(new Uri("http://appdraft.azurewebsites.net/signalr/negotiate/"));
    var sr = await r.Content.ReadAsStringAsync();
    
    

    It returns the HTML string of the page, so nothing is wrong with accessing the server.

    I don't understand, why would "http://mywebsite/signalr/negotiate" not work ?
    LIke I said prevously, if I navigate to this address in the web-browser on the Android device, it shows the negotiate JSON content fine, so the negotiate URL is accessible.

    This is so weird!!

    Like I said in the first post, the negotiation error appears only when running the app in an Android emulator on a  specific machine. I if I run the app on real device or in an emulator on another machine, everything is fine.
    Why is it only on that machine?

    Sunday, September 11, 2016 3:34 PM
  • User-125926659 posted

    Issue solved. How to close this thread?

    Monday, September 12, 2016 7:05 AM
  • User-1142886626 posted

    Hi silverbyte,

    Glad to hear this issue has been solved by yourself. Thanks for your sharing, I will introduce this experience to other forum users who face the same condition. Please mark your reply to close this case.

    Best Regards,

    Ailleen

    Tuesday, September 13, 2016 1:46 AM