erickubenka / conviva

Conviva is a simple Whatsapp Bot based on UI automation with Selenium and Testerra to answer commands in a specific group chat.
MIT License
0 stars 0 forks source link

Unable to supply property org.openqa.selenium.NoSuchSessionException: invalid session id #15

Closed erickubenka closed 1 month ago

erickubenka commented 1 month ago

Describe the bug Somehow after a long duration of run (greater > 5hours) the ChatWindow of WhatsApp become anvailable for the Framework und therfor an instance of HomePage can not be instantiated.

Full Trace:

24.05.2024 06:57:06.967 [main][WARN]: utils.DefaultExecutionUtils - Unable to supply property
org.openqa.selenium.NoSuchSessionException: invalid session id
Build info: version: '4.18.1', revision: 'b1d3319b48'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '6.1.0-20-amd64', java.version: '23-ea'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Command: [fd0a5815c1fd1d54fd6c912af81992a1, getTitle {}]
Capabilities {acceptInsecureCerts: false, browserName: chrome-headless-shell, browserVersion: 125.0.6422.60, chrome: {chromedriverVersion: 125.0.6422.60 (3ac3319bff9f..., userDataDir: /root/.conviva/userdata}, fedcm:accounts: true, goog:chromeOptions: {debuggerAddress: localhost:40969}, networkConnectionEnabled: false, pageLoadStrategy: normal, platformName: linux, proxy: Proxy(), se:cdp: ws://localhost:40969/devtoo..., se:cdpVersion: 125.0.6422.60, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:extension:minPinLength: true, webauthn:extension:prf: true, webauthn:virtualAuthenticators: true}
Session ID: fd0a5815c1fd1d54fd6c912af81992a1
        at jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62) ~[?:?]
        at java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502) ~[?:?]
        at java.lang.reflect.Constructor.newInstance(Constructor.java:486) ~[?:?]
        at org.openqa.selenium.remote.ErrorCodec.decode(ErrorCodec.java:167) ~[conviva-1-SNAPSHOT.jar:?]
        at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:138) ~[conviva-1-SNAPSHOT.jar:?]
        at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:50) ~[conviva-1-SNAPSHOT.jar:?]
        at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:190) ~[conviva-1-SNAPSHOT.jar:?]
        at org.openqa.selenium.remote.service.DriverCommandExecutor.invokeExecute(DriverCommandExecutor.java:216) ~[conviva-1-SNAPSHOT.jar:?]
        at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:174) ~[conviva-1-SNAPSHOT.jar:?]
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:519) ~[conviva-1-SNAPSHOT.jar:?]
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:592) ~[conviva-1-SNAPSHOT.jar:?]
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:596) ~[conviva-1-SNAPSHOT.jar:?]
        at org.openqa.selenium.remote.RemoteWebDriver.getTitle(RemoteWebDriver.java:306) ~[conviva-1-SNAPSHOT.jar:?]
        at eu.tsystems.mms.tic.testframework.utils.ExecutionUtils.getFailsafe(ExecutionUtils.java:31) ~[conviva-1-SNAPSHOT.jar:?]
        at eu.tsystems.mms.tic.testframework.exceptions.PageFactoryException.<init>(PageFactoryException.java:36) ~[conviva-1-SNAPSHOT.jar:?]
        at eu.tsystems.mms.tic.testframework.pageobjects.internal.DefaultPageFactory.createPageWithCheckRule(DefaultPageFactory.java:111) ~[conviva-1-SNAPSHOT.jar:?]
        at eu.tsystems.mms.tic.testframework.pageobjects.internal.DefaultPageFactory.createPage(DefaultPageFactory.java:77) ~[conviva-1-SNAPSHOT.jar:?]
        at de.codefever.conviva.api.whatsapp.WhatsAppUiBot.run(WhatsAppUiBot.java:197) ~[conviva-1-SNAPSHOT.jar:?]
        at de.codefever.conviva.ConvivaBot.main(ConvivaBot.java:48) ~[conviva-1-SNAPSHOT.jar:?]
24.05.2024 06:57:06.970 [main][WARN]: utils.DefaultExecutionUtils - Unable to supply property
org.openqa.selenium.NoSuchSessionException: invalid session id
Build info: version: '4.18.1', revision: 'b1d3319b48'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '6.1.0-20-amd64', java.version: '23-ea'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Command: [fd0a5815c1fd1d54fd6c912af81992a1, getCurrentUrl {}]
Capabilities {acceptInsecureCerts: false, browserName: chrome-headless-shell, browserVersion: 125.0.6422.60, chrome: {chromedriverVersion: 125.0.6422.60 (3ac3319bff9f..., userDataDir: /root/.conviva/userdata}, fedcm:accounts: true, goog:chromeOptions: {debuggerAddress: localhost:40969}, networkConnectionEnabled: false, pageLoadStrategy: normal, platformName: linux, proxy: Proxy(), se:cdp: ws://localhost:40969/devtoo..., se:cdpVersion: 125.0.6422.60, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:extension:minPinLength: true, webauthn:extension:prf: true, webauthn:virtualAuthenticators: true}
Session ID: fd0a5815c1fd1d54fd6c912af81992a1
        at jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62) ~[?:?]
        at java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502) ~[?:?]
        at java.lang.reflect.Constructor.newInstance(Constructor.java:486) ~[?:?]
        at org.openqa.selenium.remote.ErrorCodec.decode(ErrorCodec.java:167) ~[conviva-1-SNAPSHOT.jar:?]
        at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:138) ~[conviva-1-SNAPSHOT.jar:?]
        at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:50) ~[conviva-1-SNAPSHOT.jar:?]
        at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:190) ~[conviva-1-SNAPSHOT.jar:?]
        at org.openqa.selenium.remote.service.DriverCommandExecutor.invokeExecute(DriverCommandExecutor.java:216) ~[conviva-1-SNAPSHOT.jar:?]
        at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:174) ~[conviva-1-SNAPSHOT.jar:?]
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:519) ~[conviva-1-SNAPSHOT.jar:?]
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:592) ~[conviva-1-SNAPSHOT.jar:?]
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:596) ~[conviva-1-SNAPSHOT.jar:?]
        at org.openqa.selenium.remote.RemoteWebDriver.getCurrentUrl(RemoteWebDriver.java:313) ~[conviva-1-SNAPSHOT.jar:?]
        at eu.tsystems.mms.tic.testframework.utils.ExecutionUtils.getFailsafe(ExecutionUtils.java:31) ~[conviva-1-SNAPSHOT.jar:?]
        at eu.tsystems.mms.tic.testframework.exceptions.PageFactoryException.<init>(PageFactoryException.java:37) ~[conviva-1-SNAPSHOT.jar:?]
        at eu.tsystems.mms.tic.testframework.pageobjects.internal.DefaultPageFactory.createPageWithCheckRule(DefaultPageFactory.java:111) ~[conviva-1-SNAPSHOT.jar:?]
        at eu.tsystems.mms.tic.testframework.pageobjects.internal.DefaultPageFactory.createPage(DefaultPageFactory.java:77) ~[conviva-1-SNAPSHOT.jar:?]
        at de.codefever.conviva.api.whatsapp.WhatsAppUiBot.run(WhatsAppUiBot.java:197) ~[conviva-1-SNAPSHOT.jar:?]
        at de.codefever.conviva.ConvivaBot.main(ConvivaBot.java:48) ~[conviva-1-SNAPSHOT.jar:?]
24.05.2024 06:57:06.971 [main][ERROR]: whatsapp.WhatsAppUiBot - Error while getting messages: Could not create instance of HomePage on "(na)" ((na)), [eu.tsystems.mms.tic.testframework.pageobjects.internal.DefaultPageFactory.createPageWithCheckRule(DefaultPageFactory.java:111), eu.tsystems.mms.tic.testframework.pageobjects.internal.DefaultPageFactory.createPage(DefaultPageFactory.java:77), de.codefever.conviva.api.whatsapp.WhatsAppUiBot.run(WhatsAppUiBot.java:197), de.codefever.conviva.ConvivaBot.main(ConvivaBot.java:48)]
24.05.2024 06:57:06.971 [main][INFO]: whatsapp.WhatsAppUiBot - Messages: 95    TotalMem: 2048    FreeMem: 1542     UsedMem: 506
erickubenka commented 1 month ago

Two options. Either some swap or something like that becomes full and therefor session got killed or unavailable. Or (my guess) a timeout of 5 hours is somewhere defined for a session and therefor browser got killed.

Why I guess its the second option? Because in server logs i can see that cpu drops down two times after application start was 5 hours ago.

Possible workaround Do a restart when Error for HomePage Instantiation occurs.

And find were timeout is set.

erickubenka commented 1 month ago
unknown error: session deleted because of page crash from unknown error: cannot determine loading status from tab crashed with ChromeDriver Selenium

First attempt is to increase shm size to 2g as recommended on docker-selenium containers as well. Will check if this helps, otherwise we go for a restart option inside the code base as mentioned before.

erickubenka commented 1 month ago

Did not work, but now implemented a simple restart to see if this will avoid this issue. So baiscally chrome driver will create a new session, when the error message was detected

erickubenka commented 1 month ago

Successfully tested on server and runnign instance today. automatic restart worked fine.