Solved

Problem calling webservice locally, works remotely

Posted on 2010-11-25
4
805 Views
Last Modified: 2012-05-10
Got a slightly strange problem.  I've developed a small webservice that, in turn calls a second webservice (an API to a third party product over which I have no control!)  It all works fine from my development machine with the third-party API running on our webserver, but as soon as I deploy my webservice to the same server it breaks and throws the following error:

System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send.
---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
--- End of inner exception stack trace
--- at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) at
System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count) at
System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest) at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest) at
System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult) at
System.Threading.ExecutionContext.runTryCode(Object userData) at
System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData) at
System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult result) at System.Net.TlsStream.Write(Byte[] buffer, Int32 offset, Int32 size) at
System.Net.PooledStream.Write(Byte[] buffer, Int32 offset, Int32 size) at
System.Net.ConnectStream.WriteHeaders(Boolean async)
--- End of inner exception stack trace
--- 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
RWIncidentProc.CustomerService.CustomerHandler.GetAllCustomers(Guid securityToken) in C:\Users\kenny.munro\Documents\Visual Studio 2010\Projects\RWIncidentReporting\RWIncidentProc\Web References\CustomerService\Reference.vb:line 171 at
RWIncidentProc.OnTimeFunctions.FindCustomer(Guid CustomerGUID) in C:\Users\kenny.munro\Documents\Visual Studio 2010\Projects\RWIncidentReporting\RWIncidentProc\OnTimeFunctions.vb:line 12 at
RWIncidentProc.IncidentProcessor.ProcessIncident(Byte[] Content) in C:\Users\kenny.munro\Documents\Visual Studio 2010\Projects\RWIncidentReporting\RWIncidentProc\IncidentProcessor.vb:line 58

Anyone got any ideas what's causing this?  Any help greatly appreciated!
0
Comment
Question by:kendolondon
  • 2
4 Comments
 
LVL 11

Accepted Solution

by:
bansidhar earned 250 total points
ID: 34215452
This is a network issue. Normally web servers and most of the servers inside a firewall are configured not to accept connection on public IP from internal network. The firewall blocks all such connection.

Here is the solution:
1. You can use the local IP of the web server once you are inside the network. If both the applications are in the same server then you can use the IP 127.0.0.1 to connect to the web service. of if it is in a different machine you can use the the local IP which you can get from the server administrator.

2. You have to run your application outside the web server network

3. Most insecure (your server admin will never allow this). ask the administrator to allow public IP access from inside the network.
0
 
LVL 11

Expert Comment

by:bansidhar
ID: 34215457
Sorry, Typo in my previous post

Here are the solutions:
not
Here is the solution:

Best is use first solution
0
 
LVL 20

Expert Comment

by:BuggyCoder
ID: 34222926
use the third party service's local address to connect and not the public one.
0
 

Author Comment

by:kendolondon
ID: 34490860
Never did get to the bottom of why this was happening.  Ended up hosting on a separate machine which works fine.  Thanks for the help though!
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question