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

Update Emulator for Ngrok v3 Support #2399

Closed
wants to merge 5 commits into from

Conversation

anishprasad01
Copy link
Contributor

@anishprasad01 anishprasad01 commented Sep 13, 2022

Fixes #2389

Version 3.x of Ngrok makes changes to the config file format and the supported command line arguments. The path field has been removed from the arguments, while the region field has been moved to the config file (where it is now required rather than optional). This causes the existing version of Emulator to fail when attempting to spawn Ngrok and connect to a remote bot.

This PR updates ngrok.ts and ngrokService.ts to remove the path and region fields so they are not passed to the Ngrok instance, thereby allowing Ngrok v3 to be used with Emulator.

Specific Changes:

  • Remove path and region from from NgrokOptions.
  • Update ngrokService.ts to pass the path to the ngrok.ts constructor when creating the Ngrok instance instead of passing it as an argument to the instance.
  • Update ngrok.ts to use the path passed into the constructor instead of the path from NgrokOptions.

Remove path and region from Ngrok Options as it is not supported in the config for Ngrok 3.

Pass the path to the ctr when creating the Ngrok instance.

Update ngrok.ts to use the path passed in to the ctr instead of Ngrok Options.
@cwhitten
Copy link
Member

@anishprasad01 thank you for the contribution! would this break using Emulator with ngrok v2?

@anishprasad01
Copy link
Contributor Author

anishprasad01 commented Sep 13, 2022

@cwhitten,

I attempted to run with Ngrok v2.3.40 and was successfully able to connect to a bot hosted in Azure. Since the region field was optional in Ngrok v2, its presence should not break anything. I will perform further testing before this PR gets merged.

@coveralls
Copy link

coveralls commented Sep 13, 2022

Coverage Status

coverage: 66.953% (-0.7%) from 67.69% when pulling 3489b62 on anishprasad01/ngrok-v3-fix into d144dd2 on main.

@anishprasad01
Copy link
Contributor Author

Testing with both Ngrok v2 and v3 reveals that v2 remains supported even with the modifications made to support v3. Communication with an Azure bot is successful and no errors appear when running or exiting the application. A search of running processes after exiting the application reveals that the Ngrok process is terminated successfully.

Testing with v2:
ngrokv2

Testing with v3:
ngrokv3

@russorat
Copy link

hi! PM for ngrok here. I'd love to see this PR merged so that we could move your users to the latest version of the ngrok agent. If I can help in any way, please let me know.

@OEvgeny
Copy link
Collaborator

OEvgeny commented Mar 21, 2023

/AzurePipelines run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@OEvgeny
Copy link
Collaborator

OEvgeny commented Mar 21, 2023

Build is failing due to the test failures:

FAIL packages/app/main/src/ngrok.spec.ts
  ● the ngrok  › ngrok connect/disconnect operations › should throw if it failed to find an ngrok executable at the specified path.

    expect(received).toBe(expected) // Object.is equality

    Expected: "Error: Could not find ngrok executable at path: Applications\\ngrok. Make sure that the correct path to ngrok is configured in the Emulator app settings. Ngrok is required to receive a token from the Bot Framework token service."
    Received: "Error: Could not find ngrok executable at path: D:\\a\\1\\s\\packages\\app\\main\\src\\bin\\ngrok.exe. Make sure that the correct path to ngrok is configured in the Emulator app settings. Ngrok is required to receive a token from the Bot Framework token service."

      225 |         thrown = e;
      226 |       }
    > 227 |       expect(thrown.toString()).toBe(
          |                                 ^
      228 |         `Error: Could not find ngrok executable at path: ${path}. Make sure that the correct path to ngrok is configured in the Emulator app settings. Ngrok is required to receive a token from the Bot Framework token service.`
      229 |       );
      230 |     });

@Giustino98
Copy link

Build is failing due to the test failures:

FAIL packages/app/main/src/ngrok.spec.ts
  ● the ngrok  › ngrok connect/disconnect operations › should throw if it failed to find an ngrok executable at the specified path.

    expect(received).toBe(expected) // Object.is equality

    Expected: "Error: Could not find ngrok executable at path: Applications\\ngrok. Make sure that the correct path to ngrok is configured in the Emulator app settings. Ngrok is required to receive a token from the Bot Framework token service."
    Received: "Error: Could not find ngrok executable at path: D:\\a\\1\\s\\packages\\app\\main\\src\\bin\\ngrok.exe. Make sure that the correct path to ngrok is configured in the Emulator app settings. Ngrok is required to receive a token from the Bot Framework token service."

      225 |         thrown = e;
      226 |       }
    > 227 |       expect(thrown.toString()).toBe(
          |                                 ^
      228 |         `Error: Could not find ngrok executable at path: ${path}. Make sure that the correct path to ngrok is configured in the Emulator app settings. Ngrok is required to receive a token from the Bot Framework token service.`
      229 |       );
      230 |     });

Any update on this? Unfortunately it seems ngrok v2 is not usable anymore and Emulator is not working with any version of Ngrok v3. So, at the moment, it is not possible to contact a remote bot with Emulator.

@OEvgeny OEvgeny mentioned this pull request Jun 20, 2023
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

Successfully merging this pull request may close these issues.

Failed to spawn ngrok
6 participants