18 January 2026:


This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.



Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.

Connection refused: connect error using ANT

NewYorker123NewYorker123 Members
edited May 2013 in Sahi - Open Source

Exact Terminal Output

C:\>ant -f "C:\Program Files (x86)\Sahi\demo.xml"
Buildfile: C:\Program Files (x86)\Sahi\demo.xml

sahitests:

start:
[java] Sahi properties file = C:\Program Files (x86)\Sahi\config\sahi.properties
[java] Sahi user properties file = C:\Program Files (x86)\Sahi\userdata\config\userdata.properties
[java] Added shutdown hook.

ff:

runfftests:
[sahi]
[sahi] suiteName = C:\Program Files (x86)\Sahi\userdata\scripts\demo\demo.suite
[sahi] base = http://tester4/Console/
[sahi] sahiHost = localhost
[sahi] port = 9999
[sahi] threads = 300
[sahi] browserType = firefox
[sahi] this.isSingleSession == false
[sahi] Added shutdown hook.
[sahi] http://localhost:9999/_s_/dyn/Suite_start?suite=C:\Program+Files+(x86)\Sahi\userdata\scripts\demo\demo.suite&base=http://tester4/Console%
2F&threads=300&sahisid=sahi_932f9ef800fdf04020083b003676e72dbf23&browserType=firefox&html=C%3A%5CProgram+Files+%28x86%29%5CSahi%5Cuserdata%5Clogs%5Cplayback%5Cmydir
[sahi] java.net.ConnectException: Connection refused: connect
[sahi] at java.net.DualStackPlainSocketImpl.connect0(Native Method)
[sahi] at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:69)
[sahi] at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
[sahi] at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
[sahi] at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
[sahi] at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:157)
[sahi] at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391)
[sahi] at java.net.Socket.connect(Socket.java:579)
[sahi] at java.net.Socket.connect(Socket.java:528)
[sahi] at sun.net.NetworkClient.doConnect(NetworkClient.java:180)
[sahi] at sun.net.www.http.HttpClient.openServer(HttpClient.java:378)
..................
.......................
[sahi] STATUS:FAILURE
[java] >>>> Sahi started. Listening on port: 9999
[java] >>>> Configure your browser to use this server and port as its proxy
[java] >>>> Browse any page and CTRL-ALT-DblClick on the page to bring up the Sahi Controller
[java]
[java] Reading browser types from: C:\Program Files (x86)\Sahi\userdata\config\browser_types.xml
[java]
[parallel] Shutting down ...
[java] Java Result: 1

BUILD SUCCESSFUL
Total time: 7 minutes 0 seconds
Connection refused: connect
Terminate batch job (Y/N)?


My Demo.xml

<?xml version="1.0" encoding="ISO-8859-1"?>
<project name="demo" default="sahitests">
<property name="userdata.dir" value="C:\Program Files (x86)\Sahi\userdata"/>
<property environment="env" />
<property name="urlbase" value="sahi.co.in"/>
<taskdef name="sahi" classname="net.sf.sahi.ant.RunSahiTask" classpath="C:\Program Files (x86)\Sahi\lib\ant-sahi.jar"/>
<target name="sahitests" description="start the server and run sahi tests">
<parallel>
<antcall target="start"/>
<sequential>
<waitfor maxwait="3" maxwaitunit="minute" checkevery="100">
<http url="http://localhost/Console/"/>;
</waitfor>
<antcall target="ff"/>
</sequential>
</parallel>
</target>

<target name="ff" description="start the server and run sahi tests">
<parallel>
<sequential>
<waitfor maxwait="3" maxwaitunit="minute" checkevery="100">
<http url="http://localhost/Console/"/>;
</waitfor>
<antcall target="runfftests"/>
</sequential>
</parallel>
</target>

<target name="runfftests">
<sahi suite="C:\Program Files (x86)\Sahi\userdata\scripts\demo\demo.suite"
browserType="firefox"
baseurl="http://localhost/Console/";
sahihost="localhost"
sahiport="9999"
failureproperty="sahi.failed"
haltonfailure="false"
threads="300">
<report type="html" logdir="C:\Program Files (x86)\Sahi\userdata\logs\playback\mydir"/>
</sahi>
</target>

<target name="sahireport" description="show report">
<exec executable="C:\Program Files (x86)\Mozilla Firefox\firefox.exe">
<arg value="C:\Program Files (x86)\Sahi\userdata\logs\playback\index.htm"/>
</exec>
</target>

<target name="start" description="starts proxy">
<java classname="net.sf.sahi.Proxy" fork="true">
<classpath location="C:\Program Files (x86)\Sahi\lib\sahi.jar">
<pathelement location="C:\Program Files (x86)\Sahi\extlib\rhino\js.jar"/>
<pathelement location="C:\Program Files (x86)\Sahi\extlib\apc\commons-codec-1.3.jar"/>
<fileset dir="extlib" includes="*.jar"/>
</classpath>
<arg value="." id="basePath"/>
<arg value="userdata" id="userdataPath"/>
</java>
</target>

<target name="testglobal">
<sahi suite="C:\Program Files (x86)\Sahi\userdata\scripts\demo\globalvar.suite"
browserType="firefox"
baseurl="http://localhost/Console/";
sahihost="localhost"
sahiport="9999"
failureproperty="sahi.failed"
haltonfailure="false"
threads="3">
<report type="html"/>
<report type="junit" logdir="${userdata.dir}/temp/junit"/>
</sahi>

</target>

<target name="shouldfail">
<sahi suite="C:\Program Files (x86)\Sahi\userdata\scripts\demo\shouldfail\fail.suite"
browserType="firefox"
baseurl="http://localhost/Console/";
sahihost="localhost"
sahiport="9999"
failureproperty="sahi.failed"
haltonfailure="false"
threads="3">
<report type="html"/>
<report type="junit" logdir="${userdata.dir}/temp/junit"/>
</sahi>

</target>

<target name="fail_missing">
<sahi suite="C:\Program Files (x86)\Sahi\userdata\scripts\demo\shouldfail\fail_missing.suite"
browserType="firefox"
baseurl="http://localhost/Console/";
sahihost="localhost"
sahiport="9999"
failureproperty="sahi.failed"
haltonfailure="false"
threads="3">
<report type="html"/>
</sahi>
</target>
</project>


I also tried to stop the service using url: http://localhost:9999/_s_/dyn/stopserver

Still I am getting the connection error. Any feedback will be extremely appreciated.

Many Thanks.

Best Answers

  • Answer ✓
    this is mine, still in development.




    <project name="SAHI3" default="Sahi">
    <property name="userdata.dir" value="${basedir}/userdata"/>
    <property environment="env" />
    <property name="urlbase" value="11.100.101.11:9090"/>
    <property name="test.reports" value="userdata/logs/playback/" />
    <taskdef name="sahi" classname="net.sf.sahi.ant.RunSahiTask" classpath="lib/ant-sahi.jar"/>


    <target name="Sahi" description="start the server and run sahi tests">
    <parallel>
    <sequential>
    <waitfor maxwait="3" maxwaitunit="minute" checkevery="100">
    <http url="http://localhost:9999/logs/"/>;
    </waitfor>
    <antcall target="SahiTest"/>
    </sequential>

    </parallel>
    </target>





    <target name="SahiTest" description="Atlas Installer checking using Jenkins">
    <sahi suite="D:\Jenkins\jobs\SAHI3\workspace\SAHI_Installer\Sahi.suite"
    browserType="firefox"
    baseurl="http://11.100.101.11:9090/";
    sahihost="localhost"
    sahiport="9999"
    threads="5">
    <report type="html"/>
    <report type="junit" logdir="userdata/logs/playback/"/>
    </sahi>
    <antcall target="report-gen"/>
    <antcall target="test-html"/>
    <antcall target="failsahi"/>
    </target>
  • Answer ✓
    ignore the "still in development"
    i am running that from Jenkins. only remaining part for me is report generation.
    like you, i had lot of problems when i started with it. and, i am not a programmer which made it very difficult for me to understand each errors.

    there are few difference between mine and yours, i just use the target that runs my suite and from that target i call others like report generation and fail etc....

    what i did when i got error was, i tried running the suite using testrunner from cmd. and then compared the url that got generated from it and that with ant.


    by url, i mean this.

    http://localhost:9999/_s_/dyn/Suite_start?suite=C:\Program+Files+(x86)\Sahi\userdata\scripts\demo\demo.suite&base=http://tester4/Console%
    2F&threads=300&sahisid=sahi_932f9ef800fdf04020083b003676e72dbf23&browserType=firefox&html=C%3A%5CProgram+Files+%28x86%29%5CSahi%5Cuserdata%5Clogs%5Cplayback%5Cmydir



    try with testrunner.bat and check if its working.

Answers

  • Any one? I desperately need some help please. Can someone please copy/paste exact working copy of demo.xml with all the hard coded values (I will adjust mine accordingly.)

    Thanks.
  • Thanks for the reply.

    I didn't understand when you say still in development!! I am assuming you meant that Sahi team is working on a fix for this? Or it's just you not able to make it to work like myself. Please let me know.

    Thanks.
  • <?xml version="1.0" encoding="ISO-8859-1"?>
    <project name="demo" default="sahitests">
    <property name="userdata.dir" value="C:\Sahi\userdata"/>
    <property environment="env" />
    <property name="urlbase" value="http://localhost/Console"/>;

    <taskdef name="sahi" classname="net.sf.sahi.ant.RunSahiTask" classpath="C:\Sahi\lib\ant-sahi.jar"/>
    <target name="sahitests" description="start the server and run sahi tests">
    <parallel>
    <antcall target="start"/>
    <sequential>
    <waitfor maxwait="3" maxwaitunit="minute" checkevery="100">
    <http url="http://localhost/Console"/>;
    </waitfor>
    <antcall target="ff"/>
    <antcall target="stopsahi"/>
    </sequential>
    </parallel>
    </target>

    <target name="ff" description="start the server and run sahi tests">
    <parallel>
    <sequential>
    <waitfor maxwait="3" maxwaitunit="minute" checkevery="100">
    <http url="http://localhost/Console"/>;
    </waitfor>
    <antcall target="runfftests"/>
    </sequential>
    </parallel>
    </target>

    <target name="runfftests">
    <sahi suite="C:\Sahi\userdata\scripts\demo\demo.suite"
    browserType="firefox"
    baseurl="http://localhost/Console";
    sahihost="localhost"
    sahiport="9999"
    failureproperty="sahi.failed"
    haltonfailure="false"
    threads="2">
    <report type="html"/>
    </sahi>
    <antcall target="failsahi"/>
    </target>

    <target name="failsahi" if="sahi.failed">
    <fail message="Sahi tests failed!"/>
    </target>

    <target name="start-web" description="starts web">
    <exec executable="C:\Sahi\userdata\bin\start_sahi.sh" osfamily="unix" spawn="true"/>
    <sleep seconds="5"/>
    </target>

    <target name="stop-web" description="stop web server">
    <get dest="stopserver.htm" src="http://localhost/Console/dyn/stopserver"; ignoreerrors="true"/>
    <!--
    <delete file="stopserver.htm"/>
    -->
    </target>

    <target name="start" description="starts proxy">
    <java classname="net.sf.sahi.Proxy" fork="true">
    <classpath location="C:\Sahi\lib\sahi.jar">
    <pathelement location="C:\Sahi\extlib\rhino\js.jar"/>
    <pathelement location="C:\Sahi\extlib\apc\commons-codec-1.3.jar"/>
    <fileset dir="extlib" includes="*.jar"/>
    </classpath>
    <arg value="." id="basePath"/>
    <arg value="userdata" id="userdataPath"/>
    </java>
    </target>

    <target name="stopsahi" description="stop sahi server">
    <sahi stop="true" sahihost="localhost" sahiport="9999"/>
    </target>
    </project>

    =========

    above is my modified code, stil doesn't work. :(
Sign In or Register to comment.