Solved

Problem calling webservice locally, works remotely

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
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 is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

862 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

20 Experts available now in Live!

Get 1:1 Help Now