none
The underlying connection was closed: The connection was closed unexpectedly. RRS feed

  • Question

  • Hi,

    We install a 3rd party software in a few of our clients, today we faced the below issue when running a function that we have not faced before, the software is installed in 2 PC's, also installed in the server.

    This function works everywhere except for this one PC where it was working fine for a few months until 2 days back.

    The exception it throws is below, i cannot change anything in software code only the Client PC Configuration, i searched the error and found it could be an issue with .NET Framework, however the latest version is installed. Can you please look at the below issue and suggest or let me know if you think you know anything to solve it.

    The underlying connection was closed: The connection was closed unexpectedly.

    Error Report
    ============
    Date & Time    : Wed, 19 Jun 2019 10:59:03 GMT
    Total Messages : 1

    Message 1 of 1
    --------------
    Message : The underlying connection was closed: The connection was closed unexpectedly.
    Id      : <Unknown>
    Detail  : The underlying connection was closed: The connection was closed unexpectedly.
    Source  : Client
    Stack   : System.Net.WebException
       at System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request)
       at System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest request)
       at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
       at SystemsUnion.Connect.Client.Commons.RepositoryProvider.RepositoryProvider.GetRTParamDesignerObjects(String authentication, String licensing, String local)
       at SystemsUnion.Connect.Client.Commons.Repository.BaseRepositoryProvider.GetRTParamDesignerObjects(String s, String sAuthentication)
       at SystemsUnion.Connect.Client.Transfer.Runnable.Model.RTParamModuleManager.LoadRTParamDesignerObjects(String authentication, String languageCode, Boolean fromWeb)
       at SystemsUnion.Connect.Client.Transfer.Runnable.Model.RTParamModuleManager.Instance(String authentication, String languageCode, Boolean fromWeb)
       at SystemsUnion.Connect.Client.Transfer.AutomationDesk..ctor()

    Wednesday, June 19, 2019 9:57 AM

Answers

  • The error tells you that the program attempted to open a connection to a remote server and the remote server refused to talk back with the caller (it closed the connection).

    There isn't enough information in the error message to deduct what exactly is happening. If you don't have access to the source code of the client application, there a few things that you can do to resolve the situation:

    1) Contact the developers of the application, i.e., whoever has the code to modify and debug it.

    2) If that fails, use a tool that captures network traffic such as WireShark to capture the traffic between your client and the server and then analyze it to find out what packets they are exchanging and try to infer from there why the connection is being closed. Of course, this is likely to require a lot of knowledge about networking. For instance, it could be that the server was patched to only allow TLS1.2 and this particular client is using a lesser version, and this is why the connection was rejected.

    3) If the low-level connection succeeds but the problem occurs at a higher level, there is another tool that can be used. From the stack trace in the error message we can infer that the program is using WCF. Assuming that it follows the standards so that the WCF configuration is in the program's .config file, you can edit the .config to enable WCF logging and tracing. This generates a set of trace files that you can then open with the corresponding viewer. It gives you a lot of information about the exchange between both machines, which can aid in resolving the problem if you are expert enough on WCF to understand the trace.

    • Marked as answer by checkmate789 Monday, June 24, 2019 7:37 AM
    Wednesday, June 19, 2019 12:59 PM
    Moderator

All replies

  • You need to put a try/catch around the code and show the sack trace with the possible inner.exception message that could reveal why the exception has been thrown.

    Wednesday, June 19, 2019 11:58 AM
  • The error tells you that the program attempted to open a connection to a remote server and the remote server refused to talk back with the caller (it closed the connection).

    There isn't enough information in the error message to deduct what exactly is happening. If you don't have access to the source code of the client application, there a few things that you can do to resolve the situation:

    1) Contact the developers of the application, i.e., whoever has the code to modify and debug it.

    2) If that fails, use a tool that captures network traffic such as WireShark to capture the traffic between your client and the server and then analyze it to find out what packets they are exchanging and try to infer from there why the connection is being closed. Of course, this is likely to require a lot of knowledge about networking. For instance, it could be that the server was patched to only allow TLS1.2 and this particular client is using a lesser version, and this is why the connection was rejected.

    3) If the low-level connection succeeds but the problem occurs at a higher level, there is another tool that can be used. From the stack trace in the error message we can infer that the program is using WCF. Assuming that it follows the standards so that the WCF configuration is in the program's .config file, you can edit the .config to enable WCF logging and tracing. This generates a set of trace files that you can then open with the corresponding viewer. It gives you a lot of information about the exchange between both machines, which can aid in resolving the problem if you are expert enough on WCF to understand the trace.

    • Marked as answer by checkmate789 Monday, June 24, 2019 7:37 AM
    Wednesday, June 19, 2019 12:59 PM
    Moderator
  • Hi checkmate789,

    Based on your description, there are many reasons that will generate this exception. The following link is similar to your question, you could have a look.

    https://stackoverflow.com/questions/1459475/system-net-webexception-the-underlying-connection-was-closed-the-connection-wa

    Besides, It is best for you to provide the code that may lead to the exception so that we could solve your problem faster.

    Best Regards,

    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, June 20, 2019 1:53 AM
    Moderator
  • Thanks all for your responses, it worked fine after removing the expired anti-virus which has control of the firewall as well.

    It is an enterprise level software so I was pretty sure it was the configuration in the customer PC that was causing the issue and not the code as this is the first issue of sort out of 1000+ PC's.

    Thanks again!

    Monday, June 24, 2019 7:37 AM