SignalR Owin Host

Showing 1-14 of 14 messages
SignalR Owin Host David Fowler 12/31/11 3:45 PM
Hey guys,

Over the past few days I've done some work to decouple SignalR from
ASP.NET (yay). Now I'm trying to implement an OWIN host and I'm having
some difficulty making it work under Kayak. The code for the host is
here:

https://github.com/SignalR/SignalR/blob/owin/SignalR.Owin/OwinHost.cs

Other related classes are here:

https://github.com/SignalR/SignalR/blob/owin/SignalR.Owin/

The code I'm using to test it is here:

https://gist.github.com/1545662

When I run the server and send requests from the signalr client, the
continuation for reading the request body is never called. Louis
( pointed out that it might have something to do with the Owin host
(in this case Kayak) might be using the single threaded event loop
scheduler and my code isn't friendly for that (https://twitter.com/#!/
loudej/status/153249927768711168
).

How do I make this work?
Re: SignalR Owin Host Louis DeJardin 1/1/12 1:22 AM
That's very peculiar.

I pushed an update of Gate bits for v0.2.0, and also forked SignalR to update the Gate references and code in the SignalR owin branch.

https://github.com/loudej/signalr/tree/owin

One thing I noticed - it seems to be able to get past the POST to "/negotiate" if you comment out the .RescheduleCallbacks() middleware. Not sure why that is - but that will get you to the next GET to "/connect" which doesn't return a result.

For that - even with the reschedule middleware commented out - the eventKey "SignalrKayakGateDemo.Raw" in the InProcessSignalBus seems to arrive at the OnSignaled method before the AddHandler method. It looks like Kayak has a custom TaskScheduler in effect? Maybe a subtle race condition that the custom scheduler will repro consistently?

I'll look further - feel free to clone the loudej/signalr to checkout owin branch.

-Lou
Re: SignalR Owin Host Benjamin van der Veen 1/1/12 2:08 PM
On Sat, Dec 31, 2011 at 3:45 PM, David Fowler <davi...@gmail.com> wrote:
> https://github.com/SignalR/SignalR/blob/owin/SignalR.Owin/OwinHost.cs

If your intention is to buffer the request body into a string, you
should be appending the `text` variable, rather than assigning it,
since that callback could be invoked multiple times. (You might
re-consider buffering it into a string if you ever want to handle
binary data…)

> When I run the server and send requests from the signalr client, the
> continuation for reading the request body is never called.

Sorry, which callback exactly isn't being invoked as expected?

Re: SignalR Owin Host David Fowler 1/1/12 2:41 PM
Thanks for that, i'll change it once I get something basic working. If
you look at the host code, there's a ParseBodyAsync method:

private static Task<string> ParseBodyAsync(IDictionary<string, object>
environment)
{
    var requestBodyDelegate = GetRequestBodyDelegate(environment);

    var tcs = new TaskCompletionSource<string>();
    if (requestBodyDelegate == null)
    {
        tcs.SetResult(null);
        return tcs.Task;
    }

    string text = null;

    requestBodyDelegate.Invoke((data, continuation) =>
    {
        // TODO: Check the continuation and read async if it isn't
null
        text = Encoding.UTF8.GetString(data.Array, data.Offset,
data.Count);
        return false;
    },
    tcs.SetException,
    () => tcs.SetResult(text));

    return tcs.Task;
}

None of the callbacks seemed to be called so it's just hanging.


On Jan 1, 2:08 pm, Benjamin van der Veen <b...@bvanderveen.com> wrote:
Re: SignalR Owin Host Benjamin van der Veen 1/1/12 9:11 PM
On Jan 1, 2012, at 2:41 PM, David Fowler <davi...@gmail.com> wrote:

> None of the callbacks seemed to be called so it's just hanging.

That's strange. Hmm...The request body delegate in non-null and your client is posting non-zero-length data?

Re: SignalR Owin Host David Fowler 1/2/12 6:08 AM
If the content length is 0 the callbacks will never be called?

On Jan 1, 9:11 pm, Benjamin van der Veen <b...@bvanderveen.com> wrote:
RE: SignalR Owin Host Louis DeJardin 1/2/12 11:36 AM
It there's a non-null body delegate you should get one callback to
error or complete, at a minimum.

--
Louis - sent from mobile
From: David Fowler
Sent: 1/2/2012 6:08 AM
To: .NET HTTP Abstractions
Subject: Re: SignalR Owin Host

Re: SignalR Owin Host David Fowler 1/2/12 11:38 AM
Yea, it's just not working.
Re: SignalR Owin Host Benjamin van der Veen 1/2/12 12:07 PM
Try compiling Kayak from the latest master.
RE: SignalR Owin Host Louis DeJardin 1/2/12 3:13 PM
Yeah, I'll try running the whole stack from source under debugger...
SignalR's a great test-case, really. Very extreme requirements.

--
Louis - sent from mobile

-----Original Message-----
From: Benjamin van der Veen
Sent: 1/2/2012 12:07 PM
To: net-http-a...@googlegroups.com
Cc: .NET HTTP Abstractions
Subject: Re: SignalR Owin Host

Re: SignalR Owin Host Scott Koon 1/6/12 11:25 AM
I think it's great that David took the time and effort to get this running under Kayak and OWIN/Gate. Always good to get folks "road testing" the spec.  
RE: SignalR Owin Host Louis DeJardin 1/6/12 11:47 AM

Absolutely!

 

Say, David, are you unblocked by what was pushed up, or are you still waiting for something?

 

 

From: net-http-a...@googlegroups.com [mailto:net-http-a...@googlegroups.com] On Behalf Of Scott Koon
Sent: Friday, January 06, 2012 11:26 AM
To: net-http-a...@googlegroups.com


Subject: Re: SignalR Owin Host

 

I think it's great that David took the time and effort to get this running under Kayak and OWIN/Gate. Always good to get folks "road testing" the spec.  

On Mon, Jan 2, 2012 at 3:13 PM, Louis DeJardin <louis.d...@gmail.com> wrote:

Yeah, I'll try running the whole stack from source under debugger...
SignalR's a great test-case, really. Very extreme requirements.


--
Louis - sent from mobile

-----Original Message-----
From: Benjamin van der Veen
Sent: 1/2/2012 12:07 PM
To: net-http-a...@googlegroups.com
Cc: .NET HTTP Abstractions
Subject: Re: SignalR Owin Host

 

Re: SignalR Owin Host David Fowler 1/7/12 8:32 AM
Your fork helps alot, thanks Louis. I'll see what I can do from there.

On Jan 6, 11:47 am, Louis DeJardin <lodej...@microsoft.com> wrote:
> Absolutely!
>
> Say, David, are you unblocked by what was pushed up, or are you still waiting for something?
>
> From: net-http-a...@googlegroups.com [mailto:net-http-a...@googlegroups.com] On Behalf Of Scott Koon
> Sent: Friday, January 06, 2012 11:26 AM
> To: net-http-a...@googlegroups.com
> Subject: Re: SignalR Owin Host
>
> I think it's great that David took the time and effort to get this running under Kayak and OWIN/Gate. Always good to get folks "road testing" the spec.
> On Mon, Jan 2, 2012 at 3:13 PM, Louis DeJardin <louis.dejar...@gmail.com<mailto:louis.dejar...@gmail.com>> wrote:
> Yeah, I'll try running the whole stack from source under debugger...
> SignalR's a great test-case, really. Very extreme requirements.
>
> --
> Louis - sent from mobile
>
>
>
>
>
>
>
> -----Original Message-----
> From: Benjamin van der Veen
> Sent: 1/2/2012 12:07 PM
Re: SignalR Owin Host Louis DeJardin 1/9/12 1:44 PM
Sounds good. Something I noticed is you may need an End() on your
IResponse abstraction. It was pretty difficult to know which data
writes were intended to end the http response, and which were intended
to flush to the wire but remain writable.