BotFramework-Emulator icon indicating copy to clipboard operation
BotFramework-Emulator copied to clipboard

Update Emulator for Ngrok v3 Support

Open anishprasad01 opened this issue 3 years ago • 4 comments

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.

anishprasad01 avatar Sep 13 '22 22:09 anishprasad01

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

cwhitten avatar Sep 13 '22 23:09 cwhitten

@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.

anishprasad01 avatar Sep 13 '22 23:09 anishprasad01

Coverage Status

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

coveralls avatar Sep 13 '22 23:09 coveralls

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

anishprasad01 avatar Sep 14 '22 20:09 anishprasad01

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.

russorat avatar Feb 21 '23 22:02 russorat

/AzurePipelines run

OEvgeny avatar Mar 21 '23 17:03 OEvgeny

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Mar 21 '23 17:03 azure-pipelines[bot]

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 |     });

OEvgeny avatar Mar 21 '23 20:03 OEvgeny

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.

Giustino98 avatar May 23 '23 11:05 Giustino98