Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RemoteSwingLibraryTimeoutError: Agent port not received before timeout #33

Closed
balakrishnabilla opened this issue Nov 24, 2015 · 23 comments

Comments

@balakrishnabilla
Copy link

I am getting below error while application is running the below script from RIDE(java web start application). It opens the swing application correctly but later i get this error.
Could you please help me on this ?

Environment details :
Java : 1.7.0_55
RIDE 1.5 running on Python 2.7.6.
robotframework 2.8.3
remoteswinglibrary2.0.3
*** Settings ***
Library RemoteSwingLibrary

*** Variables ***
${JNLP URL} webice.jnlp

*** Test Cases ***
Testing java application
Set Log Level DEBUG
Start Application myjavawsapp javaws -verbose webice.jnlp 180

LOG When I run with JYBOT :

Starting test: RemoteSwing.Testing java application
20151124 19:46:05.003 : INFO : Log level changed from INFO to DEBUG
20151124 19:46:05.018 : INFO : Link to stdout
20151124 19:46:05.018 : INFO : Link to stderr
20151124 19:46:05.018 : INFO :
Starting process:
javaws -verbose webice.jnlp
20151124 19:47:05.032 : INFO :
Failed to start application: Traceback (most recent call last):
File "E:\RemoteSwing\remoteswinglibrary-2.0.3.jar\RemoteSwingLibrary.py", line 295, in start_application
self._application_started(alias, timeout=timeout, name_contains=name_contains, accept_old=False)
File "E:\RemoteSwing\remoteswinglibrary-2.0.3.jar\RemoteSwingLibrary.py", line 321, in _application_started
url = self._get_agent_address(name_contains, accept_old)
File "E:\RemoteSwing\remoteswinglibrary-2.0.3.jar\RemoteSwingLibrary.py", line 342, in _get_agent_address
raise RemoteSwingLibraryTimeoutError('Agent port not received before timeout')
RemoteSwingLibraryTimeoutError: Agent port not received before timeout

20151124 19:47:05.051 : INFO : Waiting for process to complete.
20151124 19:47:05.055 : INFO : Process completed.
20151124 19:47:05.058 : INFO : STDOUT:
20151124 19:47:05.060 : INFO : STDERR:
20151124 19:47:05.062 : FAIL : RemoteSwingLibraryTimeoutError: Agent port not received before timeout
Ending test: RemoteSwing.Testing java application

LOG When I run with PYBOT:
Starting test: RemoteSwing.Testing java application
20151124 16:17:01.097 : INFO : Log level changed from INFO to DEBUG
20151124 16:17:01.097 : INFO : Link to stdout
20151124 16:17:01.097 : INFO : Link to stderr
20151124 16:17:01.097 : INFO :
Starting process:
javaws -verbose webice.jnlp
20151124 16:20:01.115 : INFO :
Failed to start application: Traceback (most recent call last):
File "E:\RemoteSwing\remoteswinglibrary-2.0.3.jar\RemoteSwingLibrary.py", line 295, in start_application
self._application_started(alias, timeout=timeout, name_contains=name_contains, accept_old=False)
File "E:\RemoteSwing\remoteswinglibrary-2.0.3.jar\RemoteSwingLibrary.py", line 321, in _application_started
url = self._get_agent_address(name_contains, accept_old)
File "E:\RemoteSwing\remoteswinglibrary-2.0.3.jar\RemoteSwingLibrary.py", line 342, in _get_agent_address
raise RemoteSwingLibraryTimeoutError('Agent port not received before timeout')
RemoteSwingLibraryTimeoutError: Agent port not received before timeout

20151124 16:20:01.116 : INFO : Waiting for process to complete.
20151124 16:20:01.117 : INFO : Process completed.
20151124 16:20:01.117 : INFO : STDOUT:
20151124 16:20:01.119 : INFO :
STDERR: Picked up JAVA_TOOL_OPTIONS: -javaagent:"E:\RemoteSwing\remoteswinglibrary-2.0.3.jar"=127.0.0.1:64697

Exception: java.lang.IllegalStateException thrown from the UncaughtExceptionHandler in thread "JNIWrapper.ShutdownHook"
20151124 16:20:01.123 : FAIL : RemoteSwingLibraryTimeoutError: Agent port not received before timeout
Ending test: RemoteSwing.Testing java application

STD ERROR :
Picked up JAVA_TOOL_OPTIONS: -javaagent:"E:\RemoteSwing\remoteswinglibrary-2.0.3.jar"=127.0.0.1:64697

Exception: java.lang.IllegalStateException thrown from the UncaughtExceptionHandler in thread "JNIWrapper.ShutdownHook"

@balakrishnabilla
Copy link
Author

This is bit urgent can some please help me on this ? @pekkaklarck

@antonbroq
Copy link

I am also running into this exact problem, whereby the JNLP file I am required to test does not start when instantiated from within Robot Framework using RemoteSwingLibrary Start Application keyword. I also get the same error:

RemoteSwingLibraryTimeoutError: Agent port not received before timeout

Environment details
Java version "1.8.0_91"
Eclipse IDE running with robot framework jar and Maven plugin
robotframework 3.0
remoteswinglibrary 2.1.2

@WojtekKowaluk
Copy link
Contributor

Is your application take long to start? Have you tried to set timeout parameter?

@antonbroq
Copy link

Hey, thanks for your reply! I'm just working with the Oracle Notepad JNLP as a proof of concept. The app takes seconds to start outside of RF. I have not set a timeout and I believe this defaults to 60 seconds? Setting a longer timeout does not seem to help.

I am attempting to start the app like this:

Start Application test-app javaws ${JNLP} 31337

JNLP variable resolves to the location of the JNLP file on disk. When I run the same command from the commandline, the JNLP app does start.

Output from report:

Failed to start application: Traceback (most recent call last):
File "pyclasspath/RemoteSwingLibrary.py", line 362, in start_application
File "pyclasspath/RemoteSwingLibrary.py", line 410, in _application_started
File "pyclasspath/RemoteSwingLibrary.py", line 431, in _get_agent_address
RemoteSwingLibraryTimeoutError: Agent port not received before timeout

Thanks for your help!

@WojtekKowaluk
Copy link
Contributor

WojtekKowaluk commented Jul 14, 2016

It happen all the time or randomly? You mentioned maven plugin. May it be that your test run with jybot? There is known issue about such setup: #42

I think bug maybe inside Jython, so it is hard for me to fix. Can you try to run with pybot instead of jybot?

@antonbroq
Copy link

It happens all the time - I've just tried the same tests with pybot and things do work as expected. Thanks for the pointer Wojtek. So it does not seem to be the same issue, sorry about that!

@WojtekKowaluk
Copy link
Contributor

@balak143 Do you still have this problem? Some improvments were made, so this may be fixed in lastest version.

@badari412
Copy link

Hi @WojtekKowaluk I am getting the same error "RemoteSwingLibraryTimeoutError('Agent port not received before timeout')". Here's my configuration:

RobotFramework version: Robot Framework 3.0 (Python 2.7.12 on win32)

java -version: java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)

RIDE 1.5.2.1 running on Python 2.7.12.

RemoteSwingLibrary: 2.2.0

Test case:
*** Settings ***
Library RemoteSwingLibrary

*** Test Cases ***
example
Import Library OperatingSystem
Start Application myApp java -classpath "C:\example\dist*" com.example.ContentGeneratorApp
Application Started myJava

I am using both Pybot and jybot but the result is same. After I run the tests, my swing app opens immediately and the keyword "Start Application" fails with the following error:
Failed to start application: Traceback (most recent call last):
File "C:\libs\remoteswinglibrary-2.2.0.jar\RemoteSwingLibrary.py", line 305, in start_application
self._application_started(alias, timeout, name_contains, remote_port, accept_old=False)
File "C:\libs\remoteswinglibrary-2.2.0.jar\RemoteSwingLibrary.py", line 349, in _application_started
url = self._get_agent_address(name_contains, accept_old)
File "C:\libs\remoteswinglibrary-2.2.0.jar\RemoteSwingLibrary.py", line 369, in _get_agent_address
raise RemoteSwingLibraryTimeoutError('Agent port not received before timeout')
RemoteSwingLibraryTimeoutError: Agent port not received before timeout

pybot.txt
jybot.txt

Please find the attached files for further info:

@badari412
Copy link

@WojtekKowaluk @jussimalinen Can you please help me ?

@filipecduarte
Copy link

filipecduarte commented Oct 24, 2016

Hi
In your test example.

Import Library OperatingSystem
Start Application myApp java -classpath "C:\example\dist*" com.example.ContentGeneratorApp
Application Started myJava

The Start Application from the OperatingSystem you need the -javaagent: option as
-javaagent:"path_RemoteSwingLibrary_jar_file"=127.0.0.1:"system_unused_port"

After the RemoteSwingLibrary import you have:
"path_RemoteSwingLibrary_jar_file" is in robot ${REMOTESWINGLIBRARYPATH}
"system_unused_port" is in robot ${REMOTESWINGLIBRARYPORT}

@badari412
Copy link

Thanks @filipecduarte for the reply. I was trying out a few things and I imported OperatingSystem. I hope I wouldn't need it to reproduce the issue. Anyway, I think I figured out the issue. The problem is, my application waits for the user action/input (e.g. entering the username and password, clicking on login or exit buttons etc). and until the user enters or does something it just keeps waiting. And in "SwingLibrary" I had the choice of using the keyword "Start Application In Separate Thread" so I didn't face any problem at all. But looks like that keywoprd is not supported in RemoteSwingLibrary. So is there any equivalent keyword in RSL, which does the same job of "Start Application In Separate Thread" ? I tried options like starting application using a shell script etc. but the execution hangs at "Application Started" with the same error.

@badari412
Copy link

badari412 commented Oct 24, 2016

The only workaround I see as of now is entering the username and password manually while the Robot Test is in the process of running the "Start Application" keyword. None of the RSL(from 2.1.0 to 2.2.0) seem to work. They just throw the same error "RemoteSwingLibraryTimeoutError: Agent port not received before timeout" even after doing the things manually. But surprisingly RSL 2.0.3 is working. Please find the logs below

pybot when RSL2.0.3 was used.txt

pybot when RSL2.2.0 was used.txt

I simplified the test case as below:

*** Settings ***
Library RemoteSwingLibrary

*** Test Cases ***
example
Start Application myapp "C:\Program Files\Zulu\zulu-8\bin\java" -classpath "C:\libs*" com.example.contentGenerator.ContentGeneratorApp
System Exit

@WojtekKowaluk
Copy link
Contributor

WojtekKowaluk commented Nov 4, 2016

Hello, I see two separate issues here.

  • RSL can't connect to application before it shows main window

RSL use some heuristics to find correct security context it should connect to. if application shows some dialog windows before it shows main windows it can cause some problem. I think heuristic may be improved to support your case, but it require lot of research.

  • Somehow 2.0.3 can connect to your application while 2.2.0 can't.

This is interesting regression and probably something we can fix easily if we find root case.
does your remote_stdout and remote_sterr contain something interesing? (those files are linked in log files you provided. Other thing you can look into is output of java console ( https://www.java.com/en/download/help/javaconsole.xml ).

Let me know if you have any more info.

@badari412
Copy link

Thanks @WojtekKowaluk for the reply. Please find the attached logs files you asked about. I didn't find anything interesting other than a info messages. The only extra line I saw when I used RSL 2.2.0 is "Picked up _JAVA_OPTIONS: -Djava.security.policy="c:\temp\grant_all_kes0ad.policy"

RSL_2.2.0_remote_stdout_98655461-9e7a-4fa5-a8cb-b830b59bff9e.txt
RSL_2.2.0_remote_stderr_2bb3ffd0-c9cf-4c55-b96b-54071e4fef82.txt
RSL_2.0.3_remote_stderr_55399a8c-ed2b-4209-b56f-b521f315e989.txt
RSL_2.0.3_remote_stdout_fd1e3354-8ed4-4b19-b386-a8ed556cfcf0.txt

.

@cilid
Copy link

cilid commented Jan 3, 2017

@WojtekKowaluk

I am having the same issue as reported by @badari412. The difference however is that I use Java WebStart. I have tried increasing the timeout in addition to the arguments taken by the Wait Until Keyword Succeeds keyword.

Keyword 'Java Webstart' failed after retrying for 1 minute. The last error was:
RemoteSwingLibraryTimeoutError: Agent port not received before timeout

I have a login screen that gets displayed before the main window. Do you have any possible suggestions for a workaround?

I am not using Jython, just python version 3.3.5, Java 8+ and 2.2.0 of RSL.

Thank You and a Happy New Year 2017!!

@KenchuG
Copy link

KenchuG commented Dec 4, 2017

@badari412 ,

Hi Badari, I am new to remote swing library. seeking your help in fixing the similar issue that you posted above. I have downloaded JNLP file, Now i wanted to start this application via robot framework using remote swing library in my Windows 7. But getting below error. Pls help me out from this issue & let me know if you need any info from myside
image

@badari412
Copy link

@KenchuG I am not sure if I can help you but did you try setting timeout parameter ? May be your application is taking too long to start? I couldn't proceed with RemoteSwingLibrary because of the issues I mentioned above. SwingLibrary (using jython) helped me though.

@viva7867
Copy link

Any update to fix following ...
RSL can't connect to application before it shows main window

@cristii006
Copy link
Contributor

We tried to reproduce this issue but it is difficult to do it without a concrete example. Sometimes this might happen because the environment is not properly set. As a first step we would recommend to reset the $PYTHONPATH .
The issue can be re-opened if new details are provided to reproduce it.

@rasjani
Copy link
Contributor

rasjani commented Nov 7, 2018

As i started with the latest & greates 2.2.2, i was hit with very similar issue like this - eg starting webstart application and getting connection timeout.

As pointed out, 2.0.3 was apparently working but due to python3 support only coming with 2.1.0, i tried that and that also did work so i iterated over all releases since 2.1.0 and only one where i get this particular issue is within 2.2.2 release. Last working one for me: 2.2.1

Versions:

  java version "1.8.0_181"
  Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
  Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)
  Python 3.6.6
  Robot Framework 3.0.4 (Python 3.6.6 on win32)

test.robot:

  *** Settings ***
  Library    RemoteSwingLibrary

  *** Test Cases ***
  Proof Of Concept
      Start Application    customerapp  javaws assets/customerapp.jnlp
      List Windows
      Close All Dialogs
      System Exit         exit_code=0

run.cmd:

  @echo on
  call venv\Scripts\activate
  set RSL=RemoteSwingLibrary-2.2.2.jar
  set CLASSPATH=f:\assets\%RSL%;%CLASSPATH%
  robot --pythonpath assets\%RSL% test.robot
  deactivate

mihaiparvu pushed a commit that referenced this issue Nov 8, 2018
This caused similar issues as report in in #33 albeit, it can't be the
root cause for that particular report as the change that caused this was
done after the bug was reported.

Anyway, the bug here was that as there was no existing policy file,
javaagent didnt have permissions to connect RSL server, thus causing
agent timeout.
@mel-exerp
Copy link

20:04:43.178 | INFO | Failed to start application: Traceback (most recent call last): File "C:\xxxx\remoteswinglibrary-2.2.4.jar\RemoteSwingLibrary.py", line 433, in start_application self._application_started(alias, timeout, name_contains, remote_port, accept_old=False) File "C:\xxx\remoteswinglibrary-2.2.4.jar\RemoteSwingLibrary.py", line 485, in _application_started self._wait_for_api(url) File "C:\xxx\remoteswinglibrary-2.2.4.jar\RemoteSwingLibrary.py", line 472, in _wait_for_api raise RuntimeError('Connecting to api at %s has failed: %s' % (url, error)) RuntimeError: Connecting to api at 127.0.0.1:42145 has failed: ''

@pawlobanano
Copy link

pawlobanano commented May 19, 2020

Hi all,

I spent too much time on this 'issue'. In my case, it was the wrong interpretation of documentation and wrong syntax.

Here is the version of the *.robot file which eventually worked for me:

*** Settings ***
Library             OperatingSystem
Library             RemoteSwingLibrary  debug=True
Test Setup          Run Keyword         Start My App
Test Teardown       Run Keyword         Close My App

*** Keywords ***
Start My App
    Start Application   myAppAlias      javaws ${JNLP_URL}     timeout=360

Close My App
    System Exit

With that syntax, timeout is acknowledged.

I run robot (Robot Framework 3.2.1 (Python 3.8.2 on win32)) from CLI (cmdr emulator) in Windows 10 environment.
RemoteSwingLibrary provided in python path parameter like that:
--pythonpath src/robotframework/test-suite-1/lib/remoteswinglibrary-2.2.4.jar

@101HybridQA
Copy link

Hi all,

I spent too much time on this 'issue'. In my case, it was the wrong interpretation of documentation and wrong syntax.

Here is the version of the *.robot file which eventually worked for me:

*** Settings ***
Library             OperatingSystem
Library             RemoteSwingLibrary  debug=True
Test Setup          Run Keyword         Start My App
Test Teardown       Run Keyword         Close My App

*** Keywords ***
Start My App
    Start Application   myAppAlias      javaws ${JNLP_URL}     timeout=360

Close My App
    System Exit

With that syntax, timeout is acknowledged.

I run robot (Robot Framework 3.2.1 (Python 3.8.2 on win32)) from CLI (cmdr emulator) in Windows 10 environment. RemoteSwingLibrary provided in python path parameter like that: --pythonpath src/robotframework/test-suite-1/lib/remoteswinglibrary-2.2.4.jar

Hi I still get an error even I use the script

RemoteSwingLibraryTimeoutError: Agent port not received before timeout

but the application tries to open but with this error
2022-10-25_18-17-56

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests