Custom .net TCP server - c#

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

Related

How to connect to remote gRPC service

I created a gRPC service and client in C# .NET Core 3.1. When I deploy the service to localhost, I can connect to it without a problem. But when I publish the service to a IIS via WebDeploy and start it there I cannot connect to it.
For a local deployment, the channel is initialized as follows:
var channel = GrpcChannel.ForAddress("https://localhost:5001");
For the remote deployment I change it to the following value, since it starts as a HTTP service on http://localhost:5000 on the remote machine (which I also failed to find out how to change - I would prefer it to start as a HTTPS service):
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
var channel = GrpcChannel.ForAddress("http://1.2.3.4:5000");
1.2.3.4 is the IP of the remote machine, which I am able to ping. I also created a firewall rule to allow all inbound traffic on inbound port 5000.
The client application fails on the first remote call with the 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
I fail to understand which measures I have to take to create a connection to the remote service. All example gRPC code I have found so far uses localhost as a deploy point and did not help me figure out the root cause of my problem.
Any help or pointers towards what I must have missed are appreciated.
From Tutorial: Create a gRPC client and server in ASP.NET Core, a warning almost at the end of the article, says
ASP.NET Core gRPC is not currently supported on Azure App Service or IIS. The HTTP/2 implementation of Http.Sys does not support HTTP response trailing headers which gRPC relies on...
Please refer to gRPC in production for ways to run your gRPC service in production.

web api call took too long to respond ERR_CONNECTION_TIMED_OUT (TimedOut (0x274c))

I have created a very simple web API in C# and there is only one Get method. It's working fine from Visual Studio and IIS. But when I was trying to call it from client machine I was getting error XXX took too long to respond. Search google for XXX 8081 webAPI Get ERR_CONNECTION_TIMED_OUT. I have enabled CORS, increased time out and tried several other steps from StackOverflow. When I checked with fiddler I got below error: [Fiddler] The connection to 'xxx.xxx.com' failed. Error: TimedOut (0x274c). System.Net.Sockets.SocketException 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 xxx.209.10.72:8081.
I found out that I need to open a 8081 port from windows firewall on the server. I opened inbound rule for port 8081 and it resolved the issue. After that I was able to make webapi call from any client machine.

I can't connect to the server (C#)

I have Server and Client scripts in C# programming language. When I create server on my computer and from another computer I'm trying to connect to the server it says:
an existing connection was forcibly closed by the remote host
It's happening when I change the IP of the server to 0.0.0.0 (IPAdress.Any)
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
It' happening when I change the IP of the server to IPv4 which is 10.0.0.6 (On the ipconfig - IPv4).
Also I turned off the Firewall, And I opened port (11000) on website of the router.
I put in the client the public IP address of the server (which is on whatismyip.com).
The program works perfectly when it is on the local network (I mean when the both computers have the same network).
Scripts:
Server code : http://pastebin.com/awsrkjk4
Client code : http://pastebin.com/2Xrm8YnA
Does anyone know how to solve it?
First of all, check to make sure your server is actively listening on the TCP port you expect. If it is a Windows machine, from the command line try:
netstat -ano | findstr ***LISTENINGPORT***
In your case I'm guessing you should be listening on 11000.
If so, on the client side, let me know exactly where your code is breaking. I'm assuming for now it's this:
sender.Connect(new IPEndPoint(IPAddress.Parse(ip), 11000));
.. and also run a WireShark capture on the client machine.
There are plenty of quick start-up guides - basically this will allow you to see the request your Client is making across the network, & see if a connection (if any) is being established on the server.
If you ARE making a connection, then it is just being closed for another reason, then you have a code issue. If NOT, then you have a network/configuration issue. This should help you make progress.

WCF service EndPointNotFoundException - incorrect proxy server error message

I have a Visual Studio application which makes heavy use of WCF services. Normally, the team can just download the app from SVN and run and it uses proxy settings from IE and everything is fine.
A new member of the team has just tried to do the same and as soon as the code tries to connect a service client the message similar to below is shown
There was no endpoint listening at http://servername/Service.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: 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 *10.1.2.252:8080*
It is interesting that 10.1.2.252:8080 should be mentioned as I can find no mention of that in either IE proxy settings or netsh so I have no idea where it is originating from.
I can bypass the problem by adding useDefaultWebProxy="false" to the bindings but as no other users get this I want to get to the bottom of this.
Does anyone have any suggestions on where the incorrect proxy address may be originating from - (it is not in any files in the solution as I have searched for it)?

"Established connection was aborted by the software in your host machine" (IIS)

I'm trying to configure IIS 7.5 so that it can serve large (400mb) files via HTTP. The client is a C# client using WebClient.DownloadFile() (basically wrapping an HTTP GET request).
However when downloading, I occasionally get the error from the client:
An established connection was aborted by the software in your host machine
Anything I can do in either the client or IIS to prevent this error?
After much digging around, it looks like a dodgy internet connection on my side. All clients on my site disconnect at the same time, but clients on another site stay connected. Unfortunately the internet router that I have here doesnt have any connectivity logs (its a top-of-the-range linksys.. go figure) so it wasnt easy to see what the problem was.

Categories

Resources