Solved

Problem calling webservice locally, works remotely

Posted on 2010-11-25
4
803 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

While working on Silverlight and WCF application, I faced one issue where fault exception occurred at WCF operation contract is not getting propagated to Silverlight client. So after searching net I came to know that it was behavior by default for s…
Here I am going to explain creating proxies at runtime for WCF Service. So basically we use to generate proxies using Add Service Reference and then giving the Url of the WCF service then generate proxy files at client side. Ok, what if something ge…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now