Sas Gabriel
Sas Gabriel

Reputation: 1556

SignalR not working on raspberry with windows 10

The communication between my server and custom test client is working.

I add a connection from my UWP and run it on my local windows and it is working.

When i deployed my UWP on raspberry running win iot core the signal isn't received, no errors displayed in the output.

Server:

class Program
{
    static void Main(string[] args)
    {
        // This will *ONLY* bind to localhost, if you want to bind to all addresses
        // use http://*:8080 to bind to all addresses. 
        // See http://msdn.microsoft.com/en-us/library/system.net.httplistener.aspx 
        // for more information.
        string url = "http://localhost:8080";
        using (WebApp.Start<Startup>(url))
        {
            Console.WriteLine("Server running on {0}", url);
            Console.ReadLine();
        }
    }
}
public class Startup
{
    public void Configuration(IAppBuilder app)
    {
        app.UseCors(CorsOptions.AllowAll);
        app.MapSignalR();
    }
}

TestClient:

public class Program
{
    public static void Main(string[] args)
    {
        //Set connection
        string url = "http://localhost:8080";
        var connection = new HubConnection(url);
        //Make proxy to hub based on hub name on server
        var myHub = connection.CreateHubProxy("TestHub");
        //Start connection

        connection.Start();

        while (true)
        {
            Console.ReadLine();
            myHub.Invoke("SendSignal");
        }
    }
}

UWP APP:

InitializeComponent();

pushButtonValue = GpioPinValue.High;
InitGPIO();

//Set connection
string url = "http://localhost:8080";
var connection = new HubConnection(url);
//Make proxy to hub based on hub name on server
var myHub = connection.CreateHubProxy("TestHub");

//Start connection    
myHub.On("ReceiveSignal", FlipLED);
connection.Start();


//timer = new DispatcherTimer();
//timer.Interval = TimeSpan.FromMilliseconds(50);
//timer.Tick += Timer_Tick;
//timer.Start();

I have no idea what to check/do next.

Why isn't the message received when my app is running on my PI?

Upvotes: 2

Views: 709

Answers (1)

Martin Tirion
Martin Tirion

Reputation: 1236

You are listening to localhost on the Pi as well. Use the IP address or hostname of the server PC there to listen to that server as url.


If this is an answer to your question, please mark this as answer.

Upvotes: 1

Related Questions