none
Websockets don't work when using SignalR 2.0.0 with Lightswitch 2013 RRS feed

  • Question

  • Ok, now that if finally figured out the problem I will detail it here and on the SignalR Github page so that hopefully others don't have to go through the 20 hours of hairpulling I just experienced.

    Symptoms:  SignalR 2.0.0 (which I have been using for a long time and in prior versions of lightswitch) was unable to use web sockets to communicate between the web server and HTML5 client.  The message in the javascript console log was -
    WebSocket connection to 'ws://localhost:1069/signalr/connect?transport=webSockets&connectionToken=c0Q%2F%2B5snGSbn%2F%2BZZ9Wusp8VoTi83cSkhQ%2BETwBbshEc14PsrWWQwEll%2FqXrKGZ%2BqbeH89Ue%2Bj5dRZAIVUWB6wUFzjcV3%2BTgfBatBmUs2IKg5ZIQLFCsTusYc4Ryl6uks&connectionData=%5B%7B%22name%22%3A%22cearahub%22%7D%5D&tid=6' failed: Unexpected response code: 500

    (As a side note, 500 errors that don't result from navigating to a web page are extremely hard to debug (since the stack trace isn't viewable in the webpage).  Even IIS server logs were extremely non-descript.  There has to be a more verbose logging option but I couldn't find any way to get at the details of this error. 

    I tried running the Lightswitch app on multiple Azure VMs, under IIS and IIS Express and even tried rolling back to an old version of SignalR (which fails to get the old Newtonsoft dependency) and was about ready to give up.  As a last ditch effort I made an MVC 5 application and copied over all the relevant SignalR bits and alas, it worked perfectly.  I don't know how the architecture changes (mostly OWIN related) to SignalR changed its interactions with Lightswitch HTML but clearly something is wrong.  Thankfully SignalR still falls back to long polling alright, but the whole allure to SignalR is the websocket capability. 

    I hope this information is sufficient, let me know if you need any more details!

    Friday, November 1, 2013 4:42 PM

Answers

All replies

  • This is an important issue for our company, and I think a problem overall with Lightswitch's un-agile architecture.  These forums used to be active with Microsoft employees but lately support hasn't been quick enough to allow Lightswitch to be effectively used in enterprise solutions.  While I'm sure its great for creating quick CRUD applications, we are considering just creating our own ASP.NET framework to avoid the pain points that come along with the ease-of-use Lightswitch provides.
    Monday, November 4, 2013 5:29 PM
  • A LightSwitch Server project is basically a ASP.NET project without OWIN and other stuff that you get when you use some of the MVC templates.

    However, you can simply add most stuff. For example this shows how to add what is needed for MVC:

    Using MVC With Visual Studio LightSwitch

    I originally started off with Dale Morrison's work but I wanted a version that only implemented the bare minimum. So all I did was make a normal MVC5 project and compare it to the LightSwitch project and then add the missing components.

    I suspect you can just do the same thing here.

    No need to give up on LightSwitch. It is not just for simple stuff. I have nearly 100 examples you can download from http://LightSwitchHelpWebsite.com that show some very advanced stuff.


    Unleash the Power - Get the LightSwitch HTML Client book

    http://LightSwitchHelpWebsite.com

    Monday, November 4, 2013 9:48 PM
  • Hello community,

    i just started with signalr in LS Html Client (VS 2013) and read the examples i found. Now i try to implement it like Matt Sampsom describes in ASP.NET SignalR and LightSwitch (VS 2012 Update 2)!!! But nuget only shows and installs the newer version 2.0.0 of signalr. this doesnt work as described by Matt for Version 1.0.1.
    There are a few changes to OWIN. There are some articels about updating signalr 1.x to 2.x but i cant get it to work. one issue is that i cant find the template for the "owin startup class" in my VS2013.  

    does anyone has a working implementation of signalr 2.0.0 in LS Html Client? a small project or a step by step description of what to do to implement Signal r 2.0.0?
    or any idea why this owin startup class template (Add\Class\"owin startup class") is missing in my installation of VS 2013?

    Thanks in advance

    Thomas


    • Edited by DarkSideNRW Friday, November 15, 2013 5:40 AM
    Friday, November 15, 2013 5:37 AM
  • I too am having extreme difficulty getting this to work in Lightswitch 2013. I managed to get it working in MVC.

    If you are using VB like me, you will discover that the Owin Startup Class does not exist in VB. However, if you check out C#, the class is available. Nevertheless, many forums suggest that an empty class would suffice.

    What worries me is that my SignalR LS2013 VB implementation fails to even resolve/create the signalr/hubs folder according to fiddler. I have used so many combinations of the src location.

    i.e 

       <script src="../signalr/hubs"></script> or   <script src="/signalr/hubs"></script> or    <script src="signalr/hubs"></script>

    I have also followed Matt's tutorial as well as the comments following it; including Rogers. Can anyone suggest what I may be doing wrong? I understand that it may be a mission to get the latest version of SignalR to work with LS2013, but fiddler states that my hubs folder is not even being created.

    I'm sure this may help DarkSideNRW as well :)

    http://blogs.msdn.com/b/rmattsampson/archive/2013/03/14/asp-net-signalr-in-lightswitch.aspx

    Thursday, December 4, 2014 3:13 PM