Error starting browerstack local · Issue #37 · browserstack/browserstack-local-java · GitHub
Skip to content

Error starting browerstack local #37

Open

Description

@HesterLyons

Expected Behavior

Given that I have a correct access key
When I start browerstack local
Then the browserstack local object should start successfully

Actual Behavior

At l.start(options) (line 33 in BrowserStackLocalTest.java) an error is thrown:
org.json.JSONException: JSONObject["message"] is not a JSONObject.

`at org.json.JSONObject.getJSONObject(JSONObject.java:640)`
`at com.browserstack.local.Local.start(Local.java:80)`
`at com.browserstack.local.BrowserStackLocalTest.testMultipleBinary(BrowserStackLocalTest.java:33)`
    `...`

This behaviour is repeated across the project and also in different projects in which the library is used.

Steps to Reproduce the Problem

  1. Download the repository and extract
  2. Open command prompt or git bash in the extracted folder
  3. run mvn test or run from within the IDE.

browserstack local arguments

I have run the repository out of the box and changed no settings. I know that my Browserstack access credentials are correct and non-local tests run OK.

Platform details

  1. browserstack-local-java version: 1.0.1
  2. java version: 1.8
  3. os type and version: Windows 10

Details

the command Local.start() does not appear to function correctly and throws an error when invoked. The function new Local(); works OK and returns an object. The hashmap contains the correct elements.

Activity

  1. HesterLyons commented on Jan 22, 2019

    @HesterLyons
    Author

    Additional info: It appears the error is occurring due to an issue with my browserstack local (although it says it is enabled, I can't visit local pages manually either). For this I have submitted a support request. However, the error is confusing. It should report back that the local test environment is disconnected, which it doesn't do. I attach a screenshot showing the fact it's disconnected.

    State of connection:
    image

  2. ramapriyamk commented on Feb 6, 2019

    @ramapriyamk

    I am seeing the same issue when I ran the example Class as well separately just as a Java class:
    Exception in thread "main" org.json.JSONException: JSONObject["message"] is not a JSONObject.
    at org.json.JSONObject.getJSONObject(JSONObject.java:640)
    at com.browserstack.local.Local.start(Local.java:80)
    at BrowserStackLocalExample.main(BrowserStackLocalExample.java:36)

    For the following lines:
    l = new Local();
    HashMap<String, String> options = new HashMap<String, String>();
    options.put("key", access_key);
    l.start(options); //Above mentioned error is thrown at this line

    I have tried with the following browserstack local versions:
    1.0.3,1.0.2, 1.0.1, 1.0.0
    My Browserstack access credentials are correct and non-local tests ran without any connectivity issues.

    Platform Details:

    1. Maven - 3.3.9
    2. Browsertack local dependency added in POM:
    com.browserstack browserstack-local-java 1.0.0

    UPDATE:****

    When I tried with Browserstack Local version 0.3.0, then the following error message is thrown:
    Exception in thread "main" com.browserstack.local.LocalException: Disconnected
    at com.browserstack.local.Local.start(Local.java:78)

    After careful debugging, I found there is some issue at these lines inside the Local.class:

    protected LocalProcess runCommand(List command) throws IOException {
    ProcessBuilder processBuilder = new ProcessBuilder(command);
    final Process process = processBuilder.start();

    Maybe the right list of commands is not passed to the processbuilder.

  3. ramapriyamk commented on Feb 6, 2019

    @ramapriyamk

    After some more analysis, I found the following method in Local.class file to run the command , even when we ran it manually from command line it throws the same error:

    private void makeCommand(Map<String, String> options, String opCode) {
    command = new ArrayList();
    command.add(binaryPath);
    command.add("-d");
    command.add(opCode);

    command.add("--key");
    command.add(options.get("key"));

    In the above method if we remove the two lines and run then I think the local test might get enabled (though not sure what else might break)

    manually running this command from source directory:
    image

    Just by running-
    BrowserStackLocal.exe -- key yourAccessKeyValue

    The local connection is established without issues.

  4. artemklimenkov-qa commented on Feb 18, 2020

    @artemklimenkov-qa

    I am seeing the same issue. Any updates on this?

  5. RohanImmanuel commented on May 4, 2020

    @RohanImmanuel

    @artemklimenkov-qa could you confirm if you are encountering the same error with browserstack local v8.0

    https://www.browserstack.com/local-testing/releases/v8.0

  6. schurik commented on May 27, 2020

    @schurik

    I get the same error even with the latest release v8.0.1.
    I am starting Browserstack Local in a linux container running in OpenShift.
    This issue appears since 25. May. before we had no problems.

    here is the error :

    Caused by: org.json.JSONException: A JSONObject text must begin with '{' at 1 [character 2 line 1]

      | at org.json.JSONTokener.syntaxError(JSONTokener.java:433) ~[json-20160212.jar!/:na]
      | at org.json.JSONObject.(JSONObject.java:195) ~[json-20160212.jar!/:na]
      | at org.json.JSONObject.(JSONObject.java:319) ~[json-20160212.jar!/:na]
      | at com.browserstack.local.Local.start(Local.java:78) ~[browserstack-local-java-1.0.3.jar!/:na]

    What about this issue: #29

    It seems to be related!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions