Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Connecting to my own machine 2

Status
Not open for further replies.

Supra

Programmer
Dec 6, 2000
422
US
Hi folks,

I'm trying to connect to my own machine from my own server, and I'm not having much luck. I wrote a simple program to monitor connection requests and a simple Perl script to attempt to connect to it using both LWP::UserAgent and IO::Socket::INET, but neither worked. I have my router forwarding the appropriate port to my machine. The strange thing is, when I use the free online "anonymizer" with my IP:port, it works fine! I have tested LWP on Google and other sites, and it pulls them fine, so yes LWP is installed. Can anyone provide some sample code that you know works correctly so I can try it?
 
No because I'm connecting from my server which is hosted by GoDaddy, not a local server.
 
Hello Supra,

In order to test your scripts I suggest that you run both processes, the one that listens and the one that tries to make a connection, on your local machine.

Move the script to your hosted server once you have that first step working and are sure you know what's happening.

Weird thing with shadowsurf... Interesting.

Mike

The options are: fast, cheap and right - pick any two... [orientalbow] & [anakin]

Want great answers to your Tek-Tips questions? Have a look at faq219-2884
 
Hey Mike,

I'm not too familiar with running Perl locally. However, don't you think running it locally would be circumventing the issue? The script can successfully connect to Google, AltaVista, etc in my tests, but not my machine. Upon further testing today, I see that if I wait long enough, I get a timeout. I'll be setting the timeout lower for future tests. After fishing around Tek-Tips a bit more, I think I'm convinced that Shadowsurf could connect because it uses a proxy, unlike my GoDaddy script. I found some snippets here and there that use proxy_env, but I haven't looked this up on CPAN for up-to-date documentation. I will try it this evening when I get home from work and post the results here.

Thank you for your ideas guys :)
 
Hi Supra

My suggestion to run it locally first (with the connecting script attaching to 127.0.0.1) was to isolate the problem.

However, from your post just now it looks as if you've effectively done that already with your tests on Google etc.

The proxy_env approach sounds promising.

Mike

The options are: fast, cheap and right - pick any two... [orientalbow] & [anakin]

Want great answers to your Tek-Tips questions? Have a look at faq219-2884
 
Okay, so... you have a script on your GoDaddy server (the Remote server) and it's trying to connect to your machine (the Local server). The Remote server can connect find to Google and other sites but not to the Local server?

The most obvious question is: is your Local server configured to allow connections from the Internet? A lot of PCs have software firewalls on them which allow your PC to connect to any other server on the Internet, but block any connections going in the other direction. In other words, to run a server from your PC, you need to configure your firewall to allow connections from other places on the Internet to connect to your computer.

Having said that, you initiating a connection with a different server on the Internet is very different than having a different server on the Internet trying to initiate a connection with you.

-------------
Cuvou.com | The NEW Kirsle.net
 
Hi Kirsle,

Thanks for joining the thread! Unfortunately, I know it is not my local server's issue because, as stated in my first post, I am able to connect to my local server when I use Being as the local server is the constant in this test and I have only changed the remote server, this proves that it is indeed a problem with my Perl script. But thank you for reading this thread and contributing - keep the ideas coming please! :) I should be leaving work in a few minutes, and I will post my results with proxy_env shortly after!
 
Well I tried an example from CPAN and unfortunately for me, it didn't work. Here's the code I used:
Code:
#!/usr/bin/perl

print "Content-Type: text/html\n\n";

require LWP::UserAgent;
 
my $ua = LWP::UserAgent->new;
$ua->timeout(10);
$ua->env_proxy;
 
my $response = $ua->get('[URL unfurl="true"]http://IP_ADDRESS:PORT/');[/URL]
 
	if ($response->is_success) {
    		print $response->content;
	} else {
    		print $response->status_line;
	}

exit;
Now, let it be known that I am unclear as to how a proxy works, and therefore I don't understand how using $ua->env_proxy would change my results (if it did work, that is).

Any ideas from this point on are extremely appreciated!!
 
That code works fine for me if I replace IP_ADDRESS:pORT with yahoo.com (I don't think you need to specify the port if you say http:// cause it knows it's port 80 then). I do use a proxy so the $ua->env_proxy picked that up. If you don't use a proxy then you can get ride of that line.
 
Hi travs59,

the script also works for me when connecting to websites (see posts above), however it does not work when I attempt to connect to my local machine. My goal here is to figure out why can connect to my local machine, but my website cannot. Also, the reason I am specifying a port is because I am not connecting to port 80 on my local machine.

Can someone tell me why a proxy might be able to connect to my local machine using a Perl script? What is the difference in how the remote Perl script is requesting access to my machine?

Tonight I am going to connect to my machine with ShadowSurf, record the information it sends, and compare it with what my script is sending. I vaguely remember trying to connect to a port with no success, until finally I decided to send a large packet of nonsense to the port. Much to my surprise, the port picked it up. This is a long shot, and that may have been "just one of those things", but regardless it's worth a try :)

I'll post my results later tonight for anyone interested!
 
try connecting to your local machine on port 80. I doubt that is the problem but might as well eliminate it if it isn't.

- Kevin, perl coder unexceptional!
 
Hi there,

I don't have much experience with this particular type of task that you're doing but from what you've posted, I don't think it's a problem with your local server OR the perl script on the Go Daddy server.

How are you pointing to your local server from your script? Do you use an IP or domain name that is resolved through DNS?

If you use a domain name then maybe there is a difference in how shadowsurf is resolving the name as opposed to GoDaddy. Have you had GoDaddy add a specific entry to their hosts file or anything like that?

You mentioned it was timing out so those type of issues often make me look to either DNS issues or possibly the router is silenty dropping packets from all or even specific locations.

Of course, I could also be completely way off :)

 
Good ideas guys!

I am leaving work shortly so I will look into these suggestions.

KevinADC,
while I am not running a web server and therefore do not use port 80, I am still interested to see whether my machine will pick something up on that port. I will definitely give this a try when I get in.

nedmega,
I am pointing to my local server by using . I am very curious about your idea that my router may be silently dropping packets, so I will run a packet sniffer when I get home to see exactly what is going on there.

Great ideas guys MUCH thanks!!
 
Well I tried port 80 and had no luck there, and I used the packet sniffer to see if I was getting ANYTHING from my Perl script, but unfortunately it did not pick anything up.

I'm at a loss here, and I think I may have to abandon this project as I am just completely frustrated. You have provided excellent ideas and I thank you!
 
what do you enter on shadowsurf to connect to your local machine?

- Kevin, perl coder unexceptional!
 
hmmm... Maybe you should be using one of the IO modules, IO::Socket, IO::Handle, etc. But I really don't know, this is out of my range of experience.

- Kevin, perl coder unexceptional!
 
I've tried IO::Socket already, and with no success. This is something I will likely contact Shadowsurf about to ask what method they are using to connect to websites. They may not tell me, but it's worth a shot. Thank you for your continued efforts though Kevin! I believe a star is warranted for that :)
 
Supra - can you not just contact your local machine via ShadowSurf?

Mike

The options are: fast, cheap and right - pick any two.. [orientalbow] & [anakin]

Want great answers to your Tek-Tips questions? Have a look at faq219-2884
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top