Connect signalr with external server RRS feed

  • Question

  • User647012147 posted

    Hi, I have a question with signalr, i have a connection of n clients whit a external server, i want use signalr like a kind MIM(Man in the Middle), is posible that my signal server establish a connection whit the external server ??


    Friday, June 23, 2017 7:54 PM

All replies

  • User1068175894 posted

    In this post they explain how to connect to signalR from different clients, the last one is a console application. Use that code in your man in the middle server


    Saturday, June 24, 2017 12:38 PM
  • User647012147 posted

    Hello I saw the example but this does not solve my problem, I have to connect to an ip and a port, not url address, I do this through socket in a winform, but i want change to SignalR and ASP.Net

    Monday, June 26, 2017 7:50 PM
  • User-707554951 posted

    Hi alexeirojas87

    You said you want to t to an ip and a port, not url address. 

    In the following link provided by JBetancourt.


    See the following code Running in Main

    string url = "http://localhost:8089";
    using (WebApp.Start(url))
        Console.WriteLine("Server running on {0}", url);

    it is ip + port, 

    Please check again, I think it is what you want.

    Best regard


    Tuesday, June 27, 2017 9:24 AM
  • User647012147 posted

    yes of course in this code (

    string url = "http://localhost:8089";


    There is an ip and a port, sure that is for my ignorance but I thought that would not work for me, i try it and tell you, Thanks

    Tuesday, June 27, 2017 5:12 PM
  • User647012147 posted


    After test the example, still do not work for my, I think I have to explain myself better.

    I have an application (winform), which does the server function, Of which I will receive information


    public partial class Form1 : Form

    //library created for my to open a server socket tcp/ip over a given port
    WinSockServer.WinSockServer server = new WinSockServer.WinSockServer();

    delegate void SetTextCallback(string text);
    public Form1()
    server.NuevaConexion += new WinSockServer.WinSockServer.NuevaConexionEventHandler(server_NuevaConexion);
    server.DatosRecibidos += new WinSockServer.WinSockServer.DatosRecibidosEventHandler(server_DatosRecibidos);
    server.ConexionTerminada += new WinSockServer.WinSockServer.ConexionTerminadaEventHandler(server_ConexionTerminada);
    server.PuertoDeEscucha = "5002"; //Listening port
    server.Escuchar(); //I opened the connection here and wait the client connection

    void server_ConexionTerminada(System.Net.IPEndPoint IDTerminal)
    SetText("Se desconecto:" + IDTerminal.Address.ToString() + "/r/n");

    void server_DatosRecibidos(System.Net.IPEndPoint IDTerminal)
    String datosR = server.ObtenerDatos(IDTerminal);
    SetText(datosR + "/r/n");

    void server_NuevaConexion(System.Net.IPEndPoint IDTerminal)
    SetText("Se conecto:" + IDTerminal.Address.ToString() + "/r/n");

    private void SetText(string text)
    if (this.textBox1.InvokeRequired)
    SetTextCallback d = new SetTextCallback(SetText);
    this.Invoke(d, new object[] { text });
    this.textBox1.Text = this.textBox1.Text + text;

    private void button1_Click(object sender, EventArgs e)


    When I use in the SignalR project the method to connect a external server

    var hubconn = new HubConnection("http://localhost:5002");

    the connection is ok, but when I try to send something from the server application(winform) i receive this exception

    The server has committed a protocol violation. Section=ResponseStatusLine
    en System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
    en System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar)

    I think it's the headline http in the HubConnection and what I'm using in the server application one tcp/ip server socket

    Wednesday, June 28, 2017 8:12 PM