Failed to connect to , at MozRepl/RemoteObject.pm

Trying to set up WWW::Mechanize::Firefox and access Firefox using Perl.

I've installed the module and its dependencies. I'm not sure if I've understood this module properly but I'm running it on a unix (shared) server to access and drive Firefox running on a pc client.

I'm getting an error:

Failed to connect to ,  at MozRepl/RemoteObject.pm at line...

I've read various posts about setting up remote access in RemoteObject.pm and tried all approaches. Still get the error. Right now I have a little test program (http://kamasiri.com/kohkood/cgi-bin/testMechanize.cgi), which is basically as follows:

#!/usr/bin/perl

use CGI;
use CGI::Carp qw(warningsToBrowser fatalsToBrowser); 
use WWW::Mechanize::Firefox;

print "Content-type: text/htmlnn";

my $mech = WWW::Mechanize::Firefox->new();
$mech->get('http://kamasiri.com');

$mech->eval_in_page('alert("Hello Firefox")');
print "<html><body><p>yeehah!</p></body></html>";

exit;

And in RemoteObject.pm I have edited near the top as follows:

# use $ENV{MOZREPL} or localhost:4242
my $remote_machine = $ENV{REMOTE_ADDR};
$ENV{REMOTE_ADDR} = "$remote_machine:4242";
my $repl = MozRepl::RemoteObject->install_bridge(
  repl => "$ENV{REMOTE_ADDR}"
);

Am i doing something wrong here?

I've also tried hard coding the IP address of the PC client into the code. Still the same error.

Firefox is running and the MozRepl add-on is loaded and running (that's the normal source of this error, I've read).

I wondered if it's a firewall issue so I've tried on various machines including a mobile. Still the same. The fact it's not printing out the ip address and port in the error message suggest to me it's not taking these as options into the program properly.

I also wondered if its a telnet privilege issue because I'm on a shared server?

Any ideas what I can try next?


From your code your initial problem seems to be that you are not initializing your WWW::Mechanize::Firefox with the server you want to use. You have created another file called RemoteObject.pm , but it doesn't seems like you are using it.

To initialize the object you should do something like this, in your main perl file:

my $remote_machine = $ENV{REMOTE_ADDR};
my $mech = WWW::Mechanize::Firefox->new( repl => "$remote_machine:4242" );

Note that this will try to connect to the machine you are using to browse with. You said that you tried with your mobile. Do you have Firefox running with MozRepl add-on on your mobile?

In RemoteObjects.pm there is no need to set the value back to REMOTE_ADDR environment variable.

Still there can be issues with firewalls and socket privileges, but now you can at least try to connect to the correct machine.

链接地址: http://www.djcxy.com/p/57526.html

上一篇: 无法在@INC中找到MozRepl.pm(您可能需要安装MozRepl模块)

下一篇: 无法连接到MozRepl / RemoteObject.pm