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 ??
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
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
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
Cathy
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
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
Code:
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()
{
InitializeComponent();
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
}
When I use in the SignalR project the method to connect a external server
var hubconn = new HubConnection("http://localhost:5002");
hubconn.Start().Wait();
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
None
0 Points
4 Posts
Connect signalr with external server
Jun 23, 2017 07:54 PM|alexeirojas87|LINK
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 ??
thanks.
Participant
1380 Points
608 Posts
Re: Connect signalr with external server
Jun 24, 2017 12:38 PM|JBetancourt|LINK
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
https://damienbod.com/2013/11/01/signalr-messaging-with-console-server-and-client-web-client-wpf-client/
Please remember to click "Mark as Answer" the responsES that resolved your issue.
None
0 Points
4 Posts
Re: Connect signalr with external server
Jun 26, 2017 07:50 PM|alexeirojas87|LINK
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
Star
8670 Points
2882 Posts
Re: Connect signalr with external server
Jun 27, 2017 09:24 AM|Cathy Zou|LINK
Hi alexeirojas87
You said you want to t to an ip and a port, not url address.
In the following link provided by JBetancourt.
https://damienbod.com/2013/11/01/signalr-messaging-with-console-server-and-client-web-client-wpf-client/
See the following code Running in Main
it is ip + port,
Please check again, I think it is what you want.
Best regard
Cathy
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
None
0 Points
4 Posts
Re: Connect signalr with external server
Jun 27, 2017 05:12 PM|alexeirojas87|LINK
yes of course in this code (
)
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
None
0 Points
4 Posts
Re: Connect signalr with external server
Jun 28, 2017 08:12 PM|alexeirojas87|LINK
hello,
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
Code:
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()
{
InitializeComponent();
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 });
}
else
{
this.textBox1.Text = this.textBox1.Text + text;
}
}
private void button1_Click(object sender, EventArgs e)
{
server.EnviarDatos(textBox2.Text);
}
}
When I use in the SignalR project the method to connect a external server
var hubconn = new HubConnection("http://localhost:5002");
hubconn.Start().Wait();
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