Title: ListensToLogcatMessages.class function startLogcatBroadcast improvement · Issue #1352 · appium/java-client · GitHub
Open Graph Title: ListensToLogcatMessages.class function startLogcatBroadcast improvement · Issue #1352 · appium/java-client
X Title: ListensToLogcatMessages.class function startLogcatBroadcast improvement · Issue #1352 · appium/java-client
Description: The problem I tried using the 'addLogcatMessagesListener' for the appium Android Driver but it failed with an exception that it can not connect. Only after I looked into the issue more deeply I noticed, that the default port is hardcoded...
Open Graph Description: The problem I tried using the 'addLogcatMessagesListener' for the appium Android Driver but it failed with an exception that it can not connect. Only after I looked into the issue more deeply I not...
X Description: The problem I tried using the 'addLogcatMessagesListener' for the appium Android Driver but it failed with an exception that it can not connect. Only after I looked into the issue more deep...
Opengraph URL: https://github.com/appium/java-client/issues/1352
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"ListensToLogcatMessages.class function startLogcatBroadcast improvement","articleBody":"## The problem\r\n\r\nI tried using the '[addLogcatMessagesListener](https://appium.github.io/java-client/io/appium/java_client/android/ListensToLogcatMessages.html)' for the appium Android Driver but it failed with an exception that it can not connect. Only after I looked into the issue more deeply I noticed, that the default port is hardcoded into the startLogcatBroadcast function. I think this is really confusing and unnecessary.\r\n```\r\n default void startLogcatBroadcast() {\r\n this.startLogcatBroadcast(\"localhost\", 4723);\r\n }\r\n\r\n default void startLogcatBroadcast(String host) {\r\n this.startLogcatBroadcast(host, 4723);\r\n }\r\n```\r\nHowever, it is possible to use this to not use the default host and port:\r\n```\r\n default void startLogcatBroadcast(String host, int port) {\r\n this.execute(\"executeScript\", ImmutableMap.of(\"script\", \"mobile: startLogsBroadcast\", \"args\", Collections.emptyList()));\r\n\r\n URI endpointUri;\r\n try {\r\n endpointUri = new URI(String.format(\"ws://%s:%s/ws/session/%s/appium/device/logcat\", host, port, ((RemoteWebDriver)this).getSessionId()));\r\n } catch (URISyntaxException var5) {\r\n throw new IllegalArgumentException(var5);\r\n }\r\n\r\n this.getLogcatClient().connect(endpointUri);\r\n }\r\n```\r\n\r\nWhat I do not get is why ListensToLogcatMessages.class doesn't simply use the host and port by the driver calling this class/function? Is there even a point in doing logcatListening to another appium service besides the one used by the driver?\r\nIs there a reason why this should not be automated? \r\nImho what it should do is this:\r\n```\r\n default void startLogcatBroadcast() {\r\n URL remoteAdress = this.getRemoteAddress();\r\n this.startLogcatBroadcast(remoteAdress.getHost(), remoteAdress.getPort());\r\n }\r\n```\r\n\r\n\r\n## Environment\r\n\r\n* Appium version (or git revision) that exhibits the issue: 1.17.1\r\n* Desktop OS/version used to run Appium: Manjaro\r\n* Mobile platform/version under test: Android\r\n* Real device or emulator/simulator: emulator\r\n* Appium CLI or Appium.app|exe: CLI\r\n\r\n## Details\r\n\r\n\r\n## Code To Reproduce Issue [ Good To Have ]\r\nFor testing the addLogcatMessagesListener I took this code:\r\nhttps://github.com/appium/java-client/blob/master/src/test/java/io/appium/java_client/android/AndroidLogcatListenerTest.java\r\n\r\nFor creating the appium service I used this code (which will always uses any free port it finds):\r\n```\r\n public static URL createAppiumService() {\r\n AppiumServiceBuilder builder = new AppiumServiceBuilder();\r\n builder.usingAnyFreePort();\r\n builder.withArgument(GeneralServerFlag.LOG_LEVEL, LogLevel);\r\n builder.withArgument(GeneralServerFlag.LOG_TIMESTAMP);\r\n builder.withArgument(GeneralServerFlag.RELAXED_SECURITY);\r\n appium = AppiumDriverLocalService.buildService(builder);\r\n appium.start();\r\n Assert.assertTrue(appium.isRunning(), \"Der Appium Server läuft nicht!\");\r\n return appium.getUrl();\r\n }\r\n```\r\n\r\nThe driver can then be initialized like so:\r\n\r\n`AndroidDriver\u003cAndroidElement\u003e driver = new AndroidDriver\u003cAndroidElement\u003e(createAppiumService(), _YourDesiredCapsHere_);`\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n","author":{"url":"https://github.com/hwulfmeyer","@type":"Person","name":"hwulfmeyer"},"datePublished":"2020-05-26T12:16:15.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/1352/java-client/issues/1352"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:1d0dadb4-eb97-551a-efe7-fdf8d9f8e29f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A9A4:1E7DF5:CCAEF0:114DB6E:6A5F00DB |
| html-safe-nonce | 86b28f1bd1a2af84d6f4be583ee67e1d66a9e7b13e5839ab3582e4928c050de5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBOUE0OjFFN0RGNTpDQ0FFRjA6MTE0REI2RTo2QTVGMDBEQiIsInZpc2l0b3JfaWQiOiIyMzc4NTU4Nzc0NDE0NjA2NTU1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 51ac271d65a8427003054b1e0e1b90ca580f070ba2cd21c0bc0c6d41eb0c7138 |
| hovercard-subject-tag | issue:624838995 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/appium/java-client/1352/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9f34bb55ad468ad47672bc2c57d460b27c78665452da88e495a51e0b4b532986/appium/java-client/issues/1352 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9f34bb55ad468ad47672bc2c57d460b27c78665452da88e495a51e0b4b532986/appium/java-client/issues/1352 |
| og:image:alt | The problem I tried using the 'addLogcatMessagesListener' for the appium Android Driver but it failed with an exception that it can not connect. Only after I looked into the issue more deeply I not... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | hwulfmeyer |
| hostname | github.com |
| expected-hostname | github.com |
| None | bf8fa4b42b6d150def6175efb9b0f1ec8e9628d7229ee2bdf6e850e7bdad923e |
| turbo-cache-control | no-preview |
| go-import | github.com/appium/java-client git https://github.com/appium/java-client.git |
| octolytics-dimension-user_id | 3221291 |
| octolytics-dimension-user_login | appium |
| octolytics-dimension-repository_id | 18454064 |
| octolytics-dimension-repository_nwo | appium/java-client |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 18454064 |
| octolytics-dimension-repository_network_root_nwo | appium/java-client |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7debc3c6cd5de09c6e22b47a1b9982acb2aabb7b |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width