LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-10-2011, 06:47 AM   #1
HarryBoy
Member
 
Registered: Apr 2008
Distribution: MontaVista Linux Version 4.0.1, Professional Edition
Posts: 215

Rep: Reputation: 16
curl_easy_perform failing when target is behind a NAT‏


I am using curl in my c++ program to retrieve a url from a web server on two different linux machines.
Before I try to get the URL I try to connect to the server initially using the below code.

I have the following options set:

Code:
CURLcode tResult = CURLE_OK;
curl_easy_setopt ( pstdEasy, CURLOPT_HTTPHEADER, pstdTransferData->pstdHeaders  );
curl_easy_setopt ( pstdEasy, CURLOPT_HTTPGET, TRUE  );
curl_easy_setopt ( pstdEasy, CURLOPT_NOBODY, TRUE  );
curl_easy_setopt ( pstdEasy, CURLOPT_WRITEFUNCTION, OnReceiveHttpResponse  );
curl_easy_setopt ( pstdEasy, CURLOPT_WRITEDATA, pstdEasy  );

curl_easy_perform ( pstdEasy  );

the content of pstdTransferData->pstdHeaders is as follows:
User-Agent: MyDeviceName
Content-Type: text/xml
Expect:
Accept: text/xml, text/html, application/xml
Connection: Keep-Alive
Accept-Language: EN


I have two linux machines each with identical software and apache webserver the only difference is that one of them is behind a NAT with port forwarding set up.
Machine A has an address of 80.20.30.1
Machine B has an address of 192.168.200.1 which is behind a NAT with an address of 80.20.30.2.

The problem is that when I try to connect to Machine B (Which is behind the NAT) I get the response to be CURLE_GOT_NOTHING instead of CURLE_OK which is what I get when I connect to Machine A.

What could be wrong here? Why is the call failing when the target is behind a NAT.

If you need any more info just ask.

Thanks

Harry
 
Old 11-17-2011, 03:39 PM   #2
stephen8
LQ Newbie
 
Registered: Nov 2011
Posts: 3

Rep: Reputation: Disabled
Hi,

Can you capture tcp dump on both machines, open them with Wireshark and determinate if packet is reaching second box at all?
Have you managed to submit request manually using wget for example, and what was the result?
If you are able to submit successful request from the first box, also record tcp dump of that request.
Compare difference in those packets. If you are using iptables to setup your nat, can you post the output of the iptables --list
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
NAT router says target network inaccessible? smithfarm Linux - Networking 4 11-18-2011 09:36 AM
Information about bind dlz‏ coffee777 Linux - Server 2 09-18-2009 01:01 AM
alsa programming problem in set frames and buffer size‏‏ wswhp Linux - Kernel 1 12-04-2008 02:39 AM
NAT Rule for FTP failing raja_lucky22 Linux - Security 2 07-04-2005 10:31 PM
NAT Failing RH8 jhordstrom Linux - Security 3 07-30-2004 09:12 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:01 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration