function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
mharleymharley 

Problems using basicSample_cs_p sample code

Hi,

I'm just getting started and I am having a problem using the basicSample_cs_p sample code.

I am using .NET, Visual Studios and a Sforce developer account. I generated a partner WSDL file and added this as a web reference to my VStudio project.

The code compiles and runs without error. However the following statement
  loginResult = binding.login(username, password);

generates an exception with the following error message
  "The underlying connection was closed: Unable to connect to the remote server"

I have tried my developer account username and password. I also tried my "team" account username and password. All producing the same error message.

I think the problem is (and everything I have read indicates) that I need at least an Enterprise level account to use the SForce WebServices API and the team account (or a developer account generated from a team account) just isn't good enough.

Additionally ...

The source code had a few different references to the address location for the web service

SforceService. For example:
 https://www.salesforce.com/services/Soap/u/6.0
 https://www.salesforce.com/services/Soap/u/7.0

I assume that I should be using the 6.0 version since the code and .NET use the 6.0 version of the AppExchange API. Still, just to be thorough, I tried different trials with each of these addresses with the exact same result and error message.

Any help or suggestions would be appreciated.

Thanks
Mike
SuperfellSuperfell
Developer Edition accounts have API access. The error you're getting is a connectivity problem, perhaps your network blocks outbound traffic except via a proxy (or some other similar firewall issue).
mharleymharley
No network other then connecting via dial up access to the net. Nothing that I am aware of is blocking outbound traffic therefore requiring a proxy.

I am running Windows XP Home edition. There was a Windows firewall enabled by default but I disabled that pretty quickly and that didn't fix the problem.

Do I have to package, publish and create a test drive with the executable? Or should I just be able to run the executable locally?

Thanks for the response.
Mike
SuperfellSuperfell
It should just work, something is blocking the HTTPS connection to salesforce.
mharleymharley
Just confirming...

Do I have to package, publish and create a test drive with the executable? Or should I just be able to run the executable locally?

Thanks
Mike
SuperfellSuperfell
No, no need to package/publish etc.
Gareth DaviesGareth Davies

Mike

try downloading developer's sidekick (free from the AppExchange) it is written in .Net c# and uses calls like you describe. If it works so should your code.

Gareth.

mharleymharley
Gareth,

Thanks for the idea.

When I try to log into Salesforce.com using the desktop sidekick I get the same error message.
"The underlying connection was closed: Unable to connect to the remote server"

Thanks
Mike
SuperfellSuperfell
Yeah, as i said before its a conectivity issue. can you get to https://www.salesforce.com in a browser ? how about https://na1-api.salesforce.com/ ? If so, check how your browser has its proxy configured.
mharleymharley
Ok, I am using Firefox version 1.5.0.3.

Checking browser proxy configurations (under Tools/Options/General Tab/Connection settings)

With browser proxy config set to => Direct connection to the Internet.
  No problems connecting to https://www.salesforce.com or https://na1-api.salesforce.com/ through the browser.

With browser proxy config set to => Auto-Detect proxy-settings for this network.
  No problems connecting to https://www.salesforce.com or https://na1-api.salesforce.com/ through the browser.

With browser proxy config set to => Manual Proxy Configuration (for some reason this was the setting when I first looked at this)
                                                          http proxy: 127.0.0.1      Port: 5400
                                                          Not being used for all protocols.
                                                          SSL, FTP and Gopher proxy's along wkth Socks Host all have
                                                         null (empty) values for proxy and 0 (zero) for host.
                                                         Finally "No Proxy for:" field set to localhost, 127.0.0.1 and a bunch microsoft websites.
  No problems connecting to https://www.salesforce.com or https://na1-api.salesforce.com/ through the browser.

Thanks for the idea.
Mike
                        
mharleymharley
An update,

I googled "The underlying connection was closed: Unable to connect to the remote server" to see if there were any solutions to my connection problem. There were tons of results, which I spent the last two days trying with no fix.

So this morning I decided to test out Google'S WebService to see if I have the same connection problem. Long story short - I don't have the same connection problem. I then modified the SalesForce source code I've been using to use Google's Webservice and it also works fine.


This works fine using Google's WebService and WSDL:
    
    Google.GoogleSearchService   s;
    Google.GoogleSearchResult    r;

    string    google_key     = "changed for forum";
    string    search_text    = "Britney Spears";          // just to make sure I get some results

    // Create a Google Search object
    s = new Google.GoogleSearchService();

    // Invoke the WebService search method
    r = s.doGoogleSearch(google_key, search_text, 0, 1, false, "", false, "", "", "");


This generates an "The underlying connection was closed: Unable to connect to the remote server" error using SalesForces WebService and partner WSDL:

    String    un = "username changed for forum";
    String    pw = "password changed for forum";

    sforce_to_sforce.sforce.LoginResult       loginResult = null;
    sforce_to_sforce.sforce.SforceService   binding = null;

    binding = new sforce_to_sforce.sforce.SforceService();
    binding.Timeout = 60000;            
    loginResult = binding.login(un, pw);

Thoughts?

Thanks in advance
Mike

mharleymharley
After thinking about this I realized the two WebServices may not be using the same protocol.

Yup, Google's url is
  HTTP://api.google.com/search/beta2
while Salesforce's url is
  HTTPS://www.salesforce.com/services/Soap/u/6.0   **
(** I am using .NET which uses API Ver 6.0. I have tried link to 7.0 Webservice with no difference)

So it still might be something blocking access to HTTPS.

I don't have a firewall or proxy server locally just a dial up connection to the net. Still I tried the following which I found online. Where a proxy server and port were required I used the default values indicated in my post two above this one.

* http://geekswithblogs.net/ranganh/archive/2005/08/29/51474.aspx
Used "programmatic" version found at the bottom. Actually a lot of the fixes were like this. Define a proxy object with a proxy url and port and pass it into the webservice. No fix.

* http://www.topxml.com/WS-web-services/re-2660_Solving-The-underlying-connection-was-closed-when-using-WSE.aspx
Two versions here. Both attempting to override the GetWebRequest by a) inserting a method in the resource.cs file (Shwank fix) or b) using reflection to override the same method (Skeup&Zeb fix). As I type this I realize that I may not have implemented these with HTTPS protocol. Not sure if it is necessary but then I'm tired. I'll give that a try. Note the above two fixes also start setting the KeepAlive flag to false because that can cause the same problem with sequential requests and reused connections.

* Finally I found a link (http://support.microsoft.com/kb/867461/en-us) to a list of bugs that are fixed in Microsoft .NET Framework 1.0 Service Pack 3, specifically KB #819450. I don't even have .NET 1.0 installed locallly (have 1.1 and 2.0) but I thought it was worth a shot because I'm running out of ideas. Nope, not a solution.

Any additional thoughts would be appreciated.

Thanks
Mike
SuperfellSuperfell
What happens if you do this ?

binding = new sforce_to_sforce.sforce.SforceService();
binding.Url = bindingUrl.Replace("https://", "http://");
loginResult = binding.login(un, pw);
mharleymharley
I assume for the second line you meant
  binding.Url = binding.Url.Replace("https://", "http://");

With "binding.Timeout = 60000;" it times out after a minute.
Without this it sits there for a long long time.
After 5 minutes I aborted the test.

Forgot to ask last time. Is there an HTTP url for SalesForce's WebService?

Thanks for the idea
Mike
SuperfellSuperfell
That's what it was just hitting (or at least trying), although HTTPS is recommended from a security point of view. I'm not sure what's going on, seems like .NET is really unhappy about something, i've never seen this problem before. Can you try a different tool, perhaps we can work out if its .NET specific or more of an environmental problem. how about trying this

telnet www.salesforce.com 80
once connected type
GET /services/Soap/c/5.0 [hit enter twice]


mharleymharley
Morning,

I tried accessing HTTP://www.salesforce.com/services/Soap/u/6.0 again in two ways: 1) with the Url.Replace method as suggested earlier and 2) by manually modifying the the url in Reference.cs. Both tests failed to connect but they didn't return an "underlying connection was closed" error. If 'binding.Timeout=60000' was set it timed-out after a minute. If binding.Timeout wasn't set it sat there until I aborted the test 4 or 5 minutes in.

Regarding Telnet:

I'm trying to connect to www.salesforce.com with telnet now without any success. I am using the default Windows XP Telnet application and putty. The results are as follows.

Port 23:
 putty: Network error. "The network is unreachable" OR "The network timed out"
 telnet: could not open connection to the host, on port 23: Connect failed

Port 80:
  putty: It just sat there for minutes without connecting
  telnet: It just sat there for minutes without connecting


Here are the results of me trying to connect to some other public telnet hosts:

towel.blinkenlights.nl
 - Success with Putty & telnet

calcna.ab.ca
 - Success with Putty & telnet

locis.loc.gov
 - Success with Putty & telnet


So I can connect to other telnet hosts but I cannot connect to Salesforce.com via telnet.

Additional thoughts?
Mike
SuperfellSuperfell
I'm not sure what to suggest, just to double check, you can access http://www.salesforce.com/services/Soap/c/7.0 using a browser ?

Perhaps you could open a support case with your ISP ?
mharleymharley
Trying that URL in my browser returns "400 GET not supported"

I have a support ticket opened with my ISP.

Thanks
Mike


Message Edited by mharley on 05-23-2006 11:52 AM

mharleymharley
A summary of my results so far:

I can successfully telnet into other third party telnet hosts but not SalesForce's.

I can successfully connect to Google's HTTP Webservice
but not SalesForce's HTTP://www.salesforce.com/services/Soap/u/6.0

With my browser (Firefox v1.5.0.3) I can successfully connect to:
- https://na1-api.salesforce.com/
- https://www.salesforce.com/

However connecting to the following with my browser generates a "405 GET not supported" error:
- http://www.salesforce.com/services/Soap/c/7.0
- https://www.salesforce.com/services/Soap/c/7.0
- http://www.salesforce.com/services/Soap/c/6.0
- https://www.salesforce.com/services/Soap/c/6.0

I have tried a varied number of results found online as potential fixes for the "The underlying connection was closed: Unable to connect to the remote server" problem without success.

--

As soon as I can find another public HTTPS Webservice to test I will give those results.

Thanks
Mike

Message Edited by mharley on 05-23-2006 12:11 PM

SuperfellSuperfell
The 405 get not supported from the /services/... urls is the expected response and means you were able to connect to the salesforce servers.

The fact that your browser can connect but neither telnet or .NET can connect leads me to believe that you have some kind of firewall software running on your machine that is blocking connections from un-expected applications.
mharleymharley
Understood, however...

I successfully connected (via telnet) to the first three non-SalesForce telnet hosts I tried but I still cannot make the same connection to Salesforce. In addition I can successfully connect to Google's HTTP webservice but not SalesForce's HTTP webservice url (as posted above).

Anything I may have locally (and I can't find anything, i've looked, no firewall, etc.) blocking connections from un-expected applications should theoretically block everything not just SalesForce's. I may not be correct but I'm heavily leaning towards the conclusion that something is different at SalesForce's end.

Respectfully
Mike
SuperfellSuperfell
If it was a salesforce end problem, then wouldn't you expect your browser based attempts would fail as well ?
mharleymharley
Just to be clear and thorough, which browser based attempts are you referring to? (URLs?)

--

As I said above:
wrt TELNET, other hosts work, SalesForce's doesn't.
wrt connecting to an HTTP Webservice, Google's work, SalesForce's doesn't.

If something at my end was blocking the connection to these services it should block all of them not just the ones to SalesForce.

I'm just trying to solve this problem. I've tried everything that has been suggested and everything I can find online. I have success when I try to connect to non-SalesForce locations but connecting to SalesForce locations (Telnet, HTTP Webservice & HTTPS Webservice) fails. The common denominator is SalesForce, which is why I am leaning towards that being part of the problem and therefore part of the solution. Do you have any contacts with SalesForce's system administrators? Possibly they can shed some light on this problem.

Respectfully
Mike

SuperfellSuperfell
You said when you use firefox you could connect to http://www.salesforce.com/services/Soap/c/7.0 (and got a 405 get not supported, which is the expected response from our server).

If you're a customer you can open a case with support. I understand you're trying to get it working, I'm trying to help, but i don't see how it can be a salesforce problem, you can connect via your browser so its not a general networking/routing problem. I can't think what's on our end that would let your browser connect, but would stop telnet or .NET from connecting. (at the point it fails its not even like we can tell what sort of client it is, its failing the initial tcp/ip connection). Other than a personal firewall on your machine i can't think what could cause firefox to connect but not the other apps (unless firefiox is picking up a proxy server connection, but we've already been through that)
JesterJester
Also, remember, you tried the developer's sidekick and got the same issue.  That is a compiled product that works on almost everyone's machine -- so it seems like you have a network issue.

I would try the developer's sidekick and your code from home.  If that works, you'll have some internal IT people to thrash with about why your network is so dang weird.


mharleymharley
SimonF,

Could you ask your sys-admin if my "admittedly VERY cheap" ISP (295.ca) is being blocked by SalesForce possibly for spam or other related reasons?

I have a similar support ticket in for my ISP asking the same regarding SalesForce.

Thanks
Mike
SuperfellSuperfell
You would have to call support for that. The fact that you can get to the site with a browser would indicate that we're not blocking it to me.
mharleymharley
Unable to find the solution to this problem I abandoned .NET and C#.

Instead I started using PHP with an Apache server set up locally which seems to work fine.