Skip to content
This repository

Can't pass querystring when creating HubConnection #581

Closed
lance00 opened this Issue August 06, 2012 · 14 comments

4 participants

lance00 David Fowler NTaylorMullen oneroan
lance00

When creating a new hubconnection I'm passing a querystring to be used as the connectionID. Using IConnectionIdGenerator works fine however the HubConnection faults as soon as I Start. Without the querystring, Start works fine. Not sure what's wrong?

Dim test As New Dictionary(Of String, String)
test.Add("test", "one")
hubConnection = New HubConnection(My.Settings.PrintServerURL, test)

                hubConnection.Start().ContinueWith(Sub(task)
                                                       If task.IsFaulted Then
                                                           MessageBox.Show("Fault")
                                                       End If
                                                   End Sub).Wait()
David Fowler
Owner

Do you get an exception?

lance00

Check out this link to see the exception information.

https://www.sugarsync.com/pf/D6874229_7413919_455807

David Fowler
Owner

Unwrap the exception and look at the inner.

lance00

Ah here it is. Along with the stack trace.

https://www.sugarsync.com/pf/D6874229_7413919_457636

at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at SignalR.Client.Http.HttpHelper.<>c__DisplayClass2.b__0(IAsyncResult ar)
at System.Threading.Tasks.TaskFactory1.FromAsyncCoreLogic(IAsyncResult iar, Func2 endFunction, Action1 endAction, Task1 promise, Boolean requiresSynchronization)

N. Taylor Mullen
Collaborator

Can you send a repo?

David Fowler
Owner

Looks like you're getting a 404, could you look at fiddler or some kind of http tracing.

lance00

Yes. It's not finding "/negotiate" 404 - File or directory not found.
I'm using Server 2012 RC and IIS 8. Must be something I'm overlooking.

David Fowler
Owner

@lance00 does it work if you don't set the querystring?

lance00

Yes.

lance00

Actually to clarify. If I don't use a querystring, it works. If I just don't set it to a value, still get the error.

'Works
hubConnection = New HubConnection(ServerURL)

'Does not work
Dim test As New Dictionary(Of String, String)
hubConnection = New HubConnection(ServerURL, test)

'Also does not work
hubConnection = New HubConnection(My.Settings.PrintServerURL, "")

oneroan

I have the same question.
conn = new HubConnection(_url, "a=b")
it doesn' work!!!

David Fowler
Owner

We have a bug in our logic that builds the url. We'll fix this for 0.5.3. If you want to work around it for now you can append /signalr to the url:

var connection = new HubConnection("http://myserver/signalr", "a=b");
lance00

By adding "/signalr". I don't get the fault on the client now but the QueryString is not coming through at the server. I stepped through the following code on the server so I know it's being called, but the QueryString has no values?

Imports SignalR

Public Class ConnectionFactory Implements IConnectionIdGenerator

Public Function GenerateConnectionId(request As IRequest) As String Implements IConnectionIdGenerator.GenerateConnectionId
    Return request.QueryString(0)
End Function

Public Sub New()
End Sub
End Class
David Fowler
Owner

That's by design. The connection id is supposed to be generated on the server and should be unique per connection.

David Fowler davidfowl closed this issue from a commit August 08, 2012
David Fowler Fixed url creation when using custom query strings when using HubConn…
…ection.

- Added 2 more overloads to the HubConnection ctor to support using the default url.
- Added test.

Fixes #581
59de15e
David Fowler davidfowl closed this in 59de15e August 08, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.