title: SignalR self host: Connection must be started before data can be sent. Call .start() before .send()
body: <p>I know it's yet another post relating to this problem :)</p>
  
  <p>I'm trying to rewrite my project to make use of SignalR Self-Host library (as per <a href="http://www.asp.net/signalr/overview/signalr-20/getting-started-with-signalr-20/tutorial-signalr-20-self-host" rel="nofollow">this</a> tutorial), but can't get passed this error now.</p>
  
  <p>I initialise the connection as follows:</p>
  
  <pre><code>$.connection.hub.url = "http://localhost:8182/signalr";
  $.connection.hub.logging = true;
  var connection = $.connection.hub.start();
  
  console.log(connection.state());
  
  connection.done(function () {
      console.log(connection.state());
      [...] // initialising viewmodels in here...
  });
  </code></pre>
  
  <p>When the first viewmodel is initialised I get the error as per the thread subject:</p>
  
  <pre><code>[17:29:14 GMT+0100 (GMT Daylight Time)] SignalR: Auto detected cross domain url. jquery.signalR-2.0.3.js:76
  [17:29:14 GMT+0100 (GMT Daylight Time)] SignalR: Negotiating with 'http://localhost:8182/signalr/negotiate?clientProtocol=1.3'. jquery.signalR-2.0.3.js:76
  pending main.js:218
  [17:29:14 GMT+0100 (GMT Daylight Time)] SignalR: Attempting to connect to SSE endpoint 'http://localhost:8182/signalr/connect?transport=serverSentEvents&amp;connection…pdQlpKjRBpUhB0PY4itVfHasSmixQAAAB0HA7hA9gYDflrhGockG%2FZR55tLg%3D%3D&amp;tid=1'. jquery.signalR-2.0.3.js:76
  [17:29:14 GMT+0100 (GMT Daylight Time)] SignalR: EventSource connected. jquery.signalR-2.0.3.js:76
  [17:29:14 GMT+0100 (GMT Daylight Time)] SignalR: Now monitoring keep alive with a warning timeout of 13333.333333333332 and a connection lost timeout of 20000. jquery.signalR-2.0.3.js:76
  resolved main.js:220
  Object {getAccountActions: function, getIncidentActionCount: function, getIncidentActions: function, refreshAccountActions: function, refreshActions: function…}
   IncidentAction.js:12
  Uncaught Error: SignalR: Connection must be started before data can be sent. Call .start() before .send() 
  </code></pre>
  
  <p>I console.log connection state after connection.done and is clearly showing as resolved.</p>
  
  <p>Also in the first viewmodel I initialise, I console.log connection.server and all my server methods are visible there, as per the snippet above.</p>
  
  <p>Server side code:</p>
  
  <pre><code>class Program
      {
          static void Main(string[] args)
          {
              string url = "http://localhost:8182";
              using (WebApp.Start(url))
              {
                  Console.WriteLine("Server running on {0}", url);
                  Console.ReadLine();
              }
          }
      }
  </code></pre>
  
  <p>Any suggestions, why I am getting this error even though the connection is 'resolved'?</p>
  
  <p><strong>Edit:</strong> Originally I moved my Owin Startup class on the server to a different project within my solution and I assume this caused the problem. When I put it in my signalR self host project, the error is gone</p>