title: SignalR JavaScript client connect
body: <p>I'm new to SignalR and I really don't have a clue. I need to connect to a stream and retrieve some data. I have gotten some help from the owner, but they don't know how to create it with JavaScript.</p>
  
  <p>They gave me the following C# code:</p>
  
  <pre><code>private static HubConnection _hubConnection;
  private static IHubProxy _hubProxy;
  
  _hubConnection = new HubConnection("https://sesignalr.esmartapi.com/realtime");
  _hubProxy = _hubConnection.CreateHubProxy("timeseriesHub");
  _hubProxy.On&lt;ValueResult&gt;("broadCastValue", RecieveServerStreamMessageObject);
  
  _hubConnection.Start().Wait();
  
  _hubProxy.Invoke("Subscribe", assetId).Wait();
  
  
  private static void RecieveServerStreamMessageObject(ValueResult message)
  {
      Console.WriteLine(message.ValueTime.ToShortDateString() + " " + message.ValueTime.ToLongTimeString() + " - Value: " + message.Value + " (id " + message.AssetId + ")");
  }
  
  public class ValueResult
  {
      public string AssetId { get; set; }
      public int ValueCategory { get; set; }
      public DateTime ValueTime { get; set; }
      public Double Value { get; set; }
      public int ValueUnit { get; set; }
  }
  </code></pre>
  
  <p>So I tried the connection using the following JavaScript code:</p>
  
  <pre><code>var connection = $.hubConnection('https://sesignalr.esmartapi.com/realtime');
  var proxy = connection.createHubProxy('timeseriesHub');
  
  // receives broadcast messages from a hub function, called "broadcastMessage"
  proxy.on('broadcastMessage', function(message) {
      console.log(message);
  });
  
  // attempt connection, and handle errors
  connection.start({ jsonp: true })
  .done(function(){ console.log('Now connected, connection ID=' + connection.id); })
  .fail(function(){ console.log('Could not connect'); });
  </code></pre>
  
  <p>And running this gave the following error:</p>
  
  <p><strong>403 (Forbidden: JSONP is disabled.)</strong></p>
  
  <p>I think I'm supposed to recreate the C# code above with JavaScript, but my C# knowledge is limited and I have no experience with this. I'm not sure how to do this, any help is appreciated.</p>