Coder Social home page Coder Social logo

signalr / signalr Goto Github PK

View Code? Open in Web Editor NEW
9.1K 643.0 2.3K 43.59 MB

Incredibly simple real-time web for .NET

Home Page: http://signalr.net

License: Other

Shell 0.32% PowerShell 0.81% C# 77.52% JavaScript 19.17% CSS 0.21% Batchfile 0.02% HTML 1.39% TypeScript 0.31% TSQL 0.26%
signalr c-sharp asp

signalr's Introduction

ASP.NET SignalR

IMPORTANT: There will be no new features added to this product. We are in maintenance mode and only fixing critical issues. See our blog post for details. This repository hosts code and project management for ASP.NET SignalR, for use in .NET Framework applications using System.Web or Katana. If you are looking for information on ASP.NET Core SignalR, see the https://github.com/aspnet/AspNetCore/tree/main/src/SignalR repository.

ASP.NET SignalR is a library for ASP.NET developers that makes it incredibly simple to add real-time web functionality to your applications. What is "real-time web" functionality? It's the ability to have your server-side code push content to the connected clients as it happens, in real-time.

What can it be used for?

Pushing data from the server to the client (not just browser clients) has always been a tough problem. SignalR makes it dead easy and handles all the heavy lifting for you.

Documentation

See the documentation

Get it on NuGet!

Install-Package Microsoft.AspNet.SignalR

Get a sample on NuGet, straight into your app!

Install-Package Microsoft.AspNet.SignalR.Sample

LICENSE

Apache 2.0 License

Contributing

See the contribution guidelines

Building the source

git clone [email protected]:SignalR/SignalR.git (or https if you use https)

Windows

After cloning the repository, run build.cmd.

NOTE: Opening the solution requires VS 2017.

Questions?

signalr's People

Contributors

abnanda1 avatar akoeplinger avatar alex-simonov avatar analogrelay avatar ayende avatar bradygaster avatar brennanconroy avatar chenriksson avatar damianedwards avatar davidfowl avatar dougbu avatar drub0y avatar ducas avatar einari avatar gustavo-armenta avatar halter73 avatar hongmeig avatar krzysfr avatar loudej avatar matskarlsson avatar mikary avatar moozzyk avatar nberardi avatar ntaylormullen avatar paulbatum avatar pheiberg avatar pszmyd avatar thomaswr avatar wtgodbe avatar xiaohongt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

signalr's Issues

$.connection.chat 'undefined'

I'm trying to set up a test application with the sample code from the Documentation using Hub. The problem is that the code works fine if I runs it under Visual Studio Devlopment Server, but when I tried running it using Local IIS Web Server the Javascript keeps erroring out because it fails to create a chat object using '$.connection.chat'. It keeps returning 'undefined'. Please help!

Thank you!

Disconnect not invoked in a timely fashion

Not sure if this is something I'm doing wrong, or a bug. I have a hub that's implementing IDisconnect, but it doesn't seem to be invoked immediately after a client leaves the page. I have a demo page were each new client creates a new connection - every time I refresh the page, my client connection count goes up. I would expect the connection count to remain constant, as the previous client technically left the page. Here's a sample of my hub code:

https://github.com/JustinBeckwith/SignalRMap/blob/master/SignalRMap/MapHub.cs

and the demo (try hitting refresh a few times)

http://signalrmap.apphb.com/?random=true

Hubs route is too aggressive

The Hubs route is currently catching any request to an app (including static file requests when RAMMFAR is enabled) that begin with '~/signalr'. This causes issues if you have a folder or file in your project root called 'signalr', e.g. when adding a sample page to an existing app.

Suggest we should make the route only specifically match ~/signalr/hubs/js (for generated JS proxy file) and ~/signalr where there is also a custom header, e.g. X-SignalR-Hub, that would need to be added by the client-side library.

Support for batching of messages

I want to be able to something like this:

  using(var batch  = this.CreateClientsBatch())
  {
    batch.AddPlayer(stuff);
    batch.MoveSomething(etc);
    batch.UpdateScores(blah);
  }

This means that each client would receive one "message" with all three operations inside it, much like it would assuming that these operations were queued while waiting for the client to re-initiate their long-poll.

I don't have strong feelings on the design, I'll let you guys sort that out.

JavaScript to server method object binding not working

I submitted an object like { value1: 0, value2: 1 } as one of the parameters (from the client-side) and on the server-side the signature of the method was:

public void SomeMethod(...., MyClass vals)
{
}

public class MyClass
{
public int value1 { get; set; } //even tried Value1
public int value2 { get; set; } //even tried Value2
}

Always throws me error 500

SignalR Client for iOS?

My company is in the early stages of researching SignalR for use in a future iteration of our software. We would like to provide a native ios app in this future iteration and leverage SignalR from ios if possible. We were wondering if you have considered providing an objective c SignalR client as part of your roadmap.

Strong naming SignalR assemblies

Hi,

Is it possible for you guys to publish strong named versions of these assemblies as creating them manually is a PITA because of "friend" assemblies?

Thanks

V

Can't deserialize SignalCommand...

I'm working on the Redis MessageStore implementation and I need to be able to deserialize SignalCommands but the class is internal. I need to be able to deserialize SignalCommand because you guys downcast to it in Connection.cs (line 196).

Pls Halp.

Unexpected response code: 200

Running a minimal test on a local development server:

  • Chrome 14.0.835.163
  • MVC3, .Net 4
  • IIS Express
  • Static HTML file.

Chrome logs this to the JavaScript console on each page load:

Unexpected response code: 200

Clicking the message shows me that it's something to do with XHR and the HTML file but I'm not really sure what that means.

Things seem to keep working regardless.

Samples (and SignalR itself?) not working properly when hosted in Windows Azure

Hey guys,

this looks like a very promising project :)

I took the samples web application and added it as a web site to an Azure web role - unfortunately the samples do not really work the way they do locally. E.g. in the shapes sample sometimes the shapes are not communicated to other peers or the shape is even not displayed in the initiating browser...

Is there any way to get more debugging information to sort out what is going wrong?

Thanks!

Cheers,
-Christian Weyer

Microsoft MVP for Windows Azure [Architecture]
http://weblogs.thinktecture.com/cweyer

Clean up connection API

Right now the connection api (IConnection) is a little messy and some methods don't make sense to call in certain contexts. We need to clean this up a bit.

Also there's alot of things called connection that probably shouldn't be called that.

SignalR in Android Webview (or Phonegap)

Hey,

I'm trying to get SignalR working from a native android app, using the Phonegap framework.

Basically, Phonegap renders html5/js/css into a WebView (Android) or UIWebView (iOS), so I tought I would have this running pretty quickly.

So I started with a real basic page and a simple hub. Tested on a pc and also tested it using my phone's browser(s):

  • Native Android (2.3) browser
  • Dolphin browser
  • Maxthon mobile

All worked !

So I compiled a native android app using phonegap and hoped it would just work (phonegap renders into an Android Webview which uses Webkit engine I think).

This did't work.

It doesn't go any further then

$.connection.hub.start()

I don't see any javascript errors (altough I'm not sure, see below).

What's going on? What is the best way to go inspect this?

I'm having some trouble debugging this.

  • Using the Android emulator, JS errors are written to log and accessable trough 'adb logcat'. Problem is: The emulator only has access to the internet, not to the local lan. So i cannot run this on my local IIS / (express) server.
    So I need to put this on some public server to debug this (Don't have a access to one now)
  • My device (HTC Sensation) (connected trough WLan, so has access to lan) doesn't write javascript errors to log. So 'adb logcat' is of no use here (known problem with HTC devices and javascript/log)

Because phonegap doesn't use some kind full blown browser (just the WebView), I cannot debug javascript.

I tried 'weinre' (a JS console.log proxy) but it doesn't show me errors either.

My first guess whas it blocks cross-domain requests, but it seems phonegap isn't affected my cross-domain policies, because it runs from the filesystem (verified this, I have a working native phonegap 'ajax' app using external domains without issues).

Anyone here tried SignalR with phonegap (or from an Android Webview) already?

What could I do to test/debug/inspect this some more?

Thanks in advance,

Remco Ros

Reconnect client after server restart

If the web server restarts (e.g. web.config is updated) then how do I make the javascript client reconnect? The reconnection needs to try a few times until the server is back online.

Ways to help?

Do you have a roadmap on what you want help with? I am just digging into the source and I really like it - I've been using PubNub, and this is a great way to "bring it in-house".

Are there areas you want help with - such as other dependency resolvers, Mongo Implementation for IMessageStore, RabbitMq for ISignalBus, etc.?

My next goal is to get my head around creating multiple channels to the client- it looks like the group functionality supports it, Just trying to learn as much as I can at this point. Also, do you guys have a test server for checking it out through firewalls?

Thanks,
-Steve

Protcol error: Missing client id.

I have an ASP.NET MVC app hosting the chat sample (as seen on Hanselmann's blog post) which works great. I have another ASP.NET webforms app that get ~5 requests per second. The webforms app is using the Signalr client from the code behind and does a Connection.Send(msg) to the chat server when a request is received.

99% of the time it works correctly, then I get the following exception on the webforms app:

Application ID: DefaultDomain

Process ID: 4520

Exception: System.Runtime.Serialization.SerializationException

Message: Type 'Newtonsoft.Json.JsonReaderException' in Assembly 'Newtonsoft.Json, Version=4.0.2.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' is not marked as serializable.

StackTrace:    at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter, SerializationBinder binder)
   at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Write(WriteObjectInfo objectInfo, NameInfo memberNameInfo, NameInfo typeNameInfo)
   at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck)
   at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers, Boolean fCheck)
   at System.Runtime.Remoting.Channels.CrossAppDomainSerializer.SerializeObject(Object obj, MemoryStream stm)
   at System.AppDomain.Serialize(Object o)
   at System.AppDomain.MarshalObject(Object o)

which I think is coming from a thread spawned by the Signalr client. I then get the following unhandled exception from the MVC chat server:

Protcol error: Missing client id.

Stack Trace

[System.InvalidOperationException: Protcol error: Missing client id.]
at SignalR.PersistentConnection.ProcessRequestAsync(HttpContext context)
at SignalR.Web.HttpTaskAsyncHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

The exception on the chat server happens for a couple minutes, then the webforms app crashes w3wp.exe. I iisreset the webforms app and it works for another hour or so then happens again.

WebSockets always fails, reverting to long polling

On the latest versions of Chrome, Safari, and Aurora 7, the WebSocket transport seems to always fail with a message "Unexpected response code: 200", then resort to long polling. I know very little about WebSockets, but I read that the initial request is expecting a response code of 101?

I found this to be the case in my own project as well as http://chatapp.apphb.com/.

Sends being blocked

I have the simple, non-hub chat client (from hanselman's blog post) which works (http://www.mysite.com/echo). From another web server I have VB.Net code that is also sending messages to the chat server like (using the Signalr client):

Public Sub SendMessage(msg As String)
    Dim connection As New Connection("http://www.mysitecom/echo")
    connection.Start().Wait()
    connection.Send(msg)
End Sub

So, on one of the chat clients I type "test" and click send. It will echo back to me. Then I call the above code from the other server a few times and nothing appears in my chat client. I then type 'test2' in the chat client and It echos back to me 'test2' plus all the messages I sent from the other server. Here is my chat server code:

Public Class UsersConnection
    Inherits PersistentConnection
    Protected Overrides Function OnReceivedAsync(clientId As String, data As String) As System.Threading.Tasks.Task
        Logging.NewEvent() _
                    .Text("OnReceivedAsync: '{0}', '{1}'", clientId, data) _
                    .Tags("signal received") _
                    .Post()
        Return Connection.Broadcast(data)
    End Function
End Class

The logging code in the OnReceivedAsync method does not get called for the other web server until the 'test2' message is sent. Once the 'test2' message is sent from the chat client, I get a log event for all the blocked messages from other server, then a log event for 'test2'.

Long Polling performance

I am using IIS 7 and vs2011 hence why its using long polling instead of web sockets.
The issue I have is that when you refresh a page a few times sometimes it will take a long time for signalr to connect to the server, and slows down and blocks things relating to signalr and then eventually slows down the server completely.

I have tested this with the included Chat Sample.
Has anybody else experienced this? Or have any suggestions for me to try to resolve it?

Thanks

Posting a message to a Hub from an action method

I am using the hub- feature of SignalR (https://github.com/SignalR/SignalR) to publish messages to all subscribed clients:

public class NewsFeedHub : Hub {
    public void Send(string channel, string content)
    {
                Clients[channel].addMessage(content);
    }
}

This works fine when calling "Send" via Javascript, but I would also like the web application to publish messages (from within an ASP.NET MVC action method).

I already tried instantiating a new object ob NewsFeedHub and calling the Send method, but this results in an error (as the underlying "Connection" of the Hub is not set). Is there a way to use the Hub without an connection?

Signalr DateTime Request/Response disparity

I am using WCF data services to 'query' for data models from my web application, but then I use SignalR to receive 'push' updates.

WCF Data Services (OData) formats dates as a string in the format "/Date(1319493384779)/". This is fine, because I then generate client-side (javascript) viewmodels where I create actual Javascript Date() objects. SignalR also sends DateTime objects from the server to the client as "/Date(1319493384779)/", but it appears to expect an actual Date() object when passing from javascript to a server hub method via Javascript - using the above date format causes a format exception in the JSON deserializer. This is rather inefficient, because I already have a model object in javascript, and I should just be able to send it to a SignalR hub as-is.

Does anybody have any idea why this is happening?

(SO: http://stackoverflow.com/questions/7882535/signalr-datetime-request-response-disparity)

Multiple Hubs with same name not detected server side

If I have two classes deriving from Hub and they have the same [short] name I get a javascript error in the browser but no exception is thrown on the server. Would be nice if an exception was thrown server side highlighting this problem.

Message.Key and how it relates to Message.Id

Wouldn't Message.Ids be scoped to the key?

In other words if Key:foo has 20 messages and Key:bar has 10 messages, shouldn't Key:foo be numbered [0..19] and Key:bar be numbered [0..9]?

If I am using keys as 'channels' - I would want to get the lastId for a key. If my local max doesn't match for that key, I could then request an update starting with my most recent id.

It seems to me that the "GetLastId() method has limited value in these cases or I'm just not understanding it.

Unable to load SignalR.Samples project

Hi,

I have downloaded the SignalR solution from https://github.com/SignalR/SignalR and now I am trying to open SignalR solution and getting the following message from Visual Studio 2010(SP1):
"The Web project 'Signar.Samples' requires missing web components to run with Visual Studio. Would you like to download and install them usingthe Web Platform Installer now?"

It has 2 buttons in it "Yes" and "No" . After pressing "Yes" it does nothing and opens the solution but, without SignalR.Samples project. In Solution Explorer The SignalR.Samples project says "SignalR.Samples (unavailable) (The project file cannot be loaded)"

I have already run "build.cmd" which is present at the root of this solution but still I am unable to open it. Can you help me fixing this issue? I am getting no information regarding what components I am missing as per the message.

Have the long polling transport bypass ASP.NET request validation

At the moment you are required to use <httpRuntime requestValidationMode="2.0"/> in your web.config to allow "dangerous" data to be sent with requests to SingalR.

It would feel a lot better if request validation could be controlled on a more granular level and which would work with <httpRuntime requestValidationMode="4.0"/>.

A tip would be to make use of the Microsoft.Web.Infrastructure.DynamicValidationHelper.ValidationUtility class to implement a framework for turning request validation on and off.

Edit:
Updated the title to more accurately address the issue.

Could not load file or assembly 'Microsoft.Web.Infrastructure" ...

Full error: Could not load file or assembly 'Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

Hey,

this might not necessarily be SignalR related, but after I added the NuGet package and created the sample client and server, this is a runtime error I'm receiving. I already noticed, that this dll is available in the lib folder of this repository, downloaded it and tried to add it as a reference to the project. However, when I try to add it via "Add References" it tells me, that this file does not appear to be a valid assembly, COM etc. file.

Any hints? The ASP.NET version is 4.0.30319.
I'm using Visual Web Developer 2010 Express and the project created is a normal ASP.NET web application (no MVC).

Nevermind, I'm an idiot :) I installed the Ninject package and now everything is fine. My apologies, I'm not really up to date with all the new tools.

signalr/hubs js file not found when deploy to production server

I have a test application with the quick code provided from the documenation using Hubs. I've managed to run this sucessfully on my local machine (both in Developmental Environment and IIS Hosting). However, when I published this onto a production server, the page cannot load the signalr/hubs JS file. I even tried to browse to it manually and received a 404 error. I should say that I got this working on one server running IIS7 and failed to get it to work on a different one running IIS6, so I'm not sure if there's some settings in IIS that's preventing the signalr/hubs js file from being generated. Looks like someone else besides me also running into this problem too (although he cannot get it to work on IIS7 or IIS6)

http://stackoverflow.com/questions/8053229/signalr-works-in-visual-studio-but-gives-a-404-error-when-deployed-to-iis

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.