ClientWebSocket wss - Unable to connect to the remote server - c#

I have created a WebSocket server in NodeJs and hosted it on GCP. The URL for the server is wss://scramblegram.bluemsoftware.com
I created a WebSocket client using ClientWebSocket C# core 5.0.
Here is my issue
If I connect to wss://scramblegram.bluemsoftware.com using my client ClientWebSocket I get "Unable to connect to the remote server"
If I connect to wss://scramblegram.bluemsoftware.com using https://www.websocket.org/echo.html it works perfectly.
If I connect to wss://echo.websocket.org using my client ClientWebSocket it works perfectly.
can someone explain what is going on and how I can debug and solve this? It makes no sense
[Edit]
Code
https://github.com/endel/NativeWebSocket/blob/master/NativeWebSocket/Assets/WebSocket/WebSocket.cs
WebSocket ws = new WebSocket("wss://scramblegram.bluemsoftware.com");
await ws.Connect();

Kindly post the code to your Custom C# Web Socket client...
We cannot try to help without seeing your code.
Ok so many things might be wrong. It might be that the remote host is behind a firewall that's blocking your web socket client machine...
Or TLS version issues. So many things can be wrong. So it's hard to tell.
I will also suggest if you check message and it's not informative enough, try checking the Github page of that Web socket client that you are using for issues related.
But most likely, the remote firewall is blocking requests from your local machine.
That's my thought.

Related

TCP connection to client internal port with Blazor server app

I want to make a website that connects to a clients internal server through a TCP connection in order to get a stream of data from an internal server in the clients computer (at a specific port).
There is a 3rd party program that when running simulations creates a 'telemetry server' at a specific port in the clients computer. I want my website to connect to that port on the clients computer and do stuff (plots) with that output.
I read about Blazor server-side app and though I give it a try since I know C# and I already wrote a program to graph said telemetry output data in C#. Now I want to make my program available to others though a website.
My program connects through System.Net.Sockets.TcpClient without problem. I even tested the connection on Blazor server-side app and it connects when the server is running on my computer.
System.Net.Sockets.TcpClient tcpclnt = new System.Net.Sockets.TcpClient();
state = "Connecting.....";
tcpclnt.Connect(myIp, 15151); // Telemetry server in port 15151
stm = tcpclnt.GetStream();
The problem is when I host my Blazor website in Azure, it is not longer able to connect. I tried writing my public IP in myIp and it doesn't work.
Unfortunately I don't get info error output from Blazor since the website just freezes with "An error has occurred..." message.
I don't know much about this (TCP connections, web connection rules, ports..) and would appreciate any leads on what could be wrong or if it is even possible.
EDIT:
I'm using server-side as suggested here since a client-side app wont be allowed to connect How can I use Socket in Blazor Client-side?
Are you using a Azure web app?
You might want to consider adding Azure Network Gateways to handle Routing rules. I think all apps and VM's in Azure need a application gateway to communicate outside of the Azure subnet.

Custom .net TCP server

Created .net custom tcp server and client using tcplistener. Taks is simple to exchange the data. I have Windows server, on which I am able to communicate. Within network also I am able to communicate. When I deploy this same on our web server, public IP is not accepting connections. At client side it throws time out error:
A connection attempt failed because the connected party did not
properly respond after a period of time, or established connection
failed because connected host has failed to respond .....
Trace route shows request is going there till server and at the end its not showing time out. Server is VM on azure.
Add the endpoint to the Azure configuration:
https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-set-up-endpoints/
Thanks for your help. It was firewall issue. It is resolved but I am clueless about the problem. Firewall ports opened earlier did not worked. so I stopped firewall and I found its working. later on I started and firewall it again worked. strange....fire wall is not updated it seems.
Thanks.
Kishor

SignalR 2.2.0 WebSocket error connecting to hub

I have an ASP.Net MVC application that I have added SignalR to. After following the "Getting Started" tutorial (with modifications of course since it's going in my application) I got it working on localhost. However once it's in the production environment, I get the following error:
WebSocket connection to 'ws://xxxxx/signalr/connect?transport=webSockets&clientProtocol=1.5&connectionToken=xxxxx' failed: Connection closed before receiving a handshake response.
I can access /signalr/hubs (I get a js file). Any ideas as to why this would happen?
This may be due to the fact that your web server doesn't support WebSockets (IIS 7.5, for instance. It may also be due to the fact that you are using a "proxy" server like ARR and it just cannot "route" WebSocket requests.
The first thing I would try to do is to disable WebSockets on SignalR, just as a debug tool. Here's how: SignalR - How do I disable WebSockets
If your problem persists, it's a general SignalR problem but at least you will have a more specific error. If the problem stops, now you know it is a server issue.

Unable to connect IMAP server using StreamSocket when we are behind the Proxy

I'm writing a simple C# Store app to check email messages for IMAP. I'm using StreamSocket to connect IMAP server. But the problem is, when we are behind the proxy we are unable to connect to IMAP server and getting below error message.
"A connection attempt failed because the connected party did not
properly respond after a period of time, or established connection
failed because connected host has failed to respond. (Exception from
HRESULT: 0x8007274C)".
I have added the code snippet for the reference.
StreamSocket Socket = new StreamSocket();
await Socket.ConnectAsync(new HostName("imap.gmail.com"), "993", SocketProtectionLevel.SslAllowNullEncryption);
But the same code is working fine when there is no proxy.
Could you please help regarding this problem?
My Development Environment is C# using VS2013 with Windows 8.1 Operating System.
Thanks in advance.
The proxy you refer to is probably a web proxy only and all access to the outside is only allowed through this proxy. This means, that only web traffic (e.g. http, https and proxied ftp) can pass, but not other procols like IMAP, SMTP (mail sending) etc - because these cannot be tunneled through a HTTP proxy.

C# HttpListener - can't see the transport

I am using HttpListener in my application. Both server and client are in my local machine. I am able to send requests from the client and send responses back from the server - all works OK.
The problem is that I am unable to view the http requests/responses using Wireshark. If the server and the client are on different machines then I am able to view those requests/responses.
Does anyone know why it happens?
Thanks.
The problem is with Wireshark itself as far as I can see.
This link explains it better: http://wiki.wireshark.org/CaptureSetup/Loopback

Categories

Resources