Add support for Browsers & Web Sockets#29
Conversation
package.json
Outdated
| "is-buffer": "^2.0.3", | ||
| "jssha": "^2.3.1", | ||
| "ms-rest-azure": "^2.5.9", | ||
| "rhea": "^0.3.9", |
There was a problem hiding this comment.
I remember a comment about rhea being a peer dependency -- not sure if that is a relevant piece of information.
There was a problem hiding this comment.
That was rhea-promise.
Amar once mentioned that we shouldnt take a dependency on rhea directly and that we should use rhea-promise instead. I dont recall the reason why though...
There was a problem hiding this comment.
If the rhea version resolved in amqp-common doesnt match with that in rhea-promise, we might end up with 2 versions of rhea correct?
Wasnt this was the reason why rhea-promise is a peer dependency in amqp-common?
If so, then rhea should be a peer dependency as well.
package.json
Outdated
| "is-buffer": "^2.0.3", | ||
| "jssha": "^2.3.1", | ||
| "ms-rest-azure": "^2.5.9", | ||
| "rhea": "^0.3.9", |
There was a problem hiding this comment.
That was rhea-promise.
Amar once mentioned that we shouldnt take a dependency on rhea directly and that we should use rhea-promise instead. I dont recall the reason why though...
package.json
Outdated
| "build": "npm run tslint && npm run tsc && cross-env rollup -c", | ||
| "test": "npm run build && npm run unit", | ||
| "unit": "nyc --reporter=lcov --reporter=text-lcov mocha -r ts-node/register -t 50000 ./tests/**/*.spec.ts", | ||
| "unit": "cross-env TS_NODE_COMPILER_OPTIONS=\"{\\\"module\\\":\\\"commonjs\\\"}\" nyc --reporter=lcov --reporter=text-lcov mocha -r ts-node/register -t 50000 ./tests/**/*.spec.ts", |
There was a problem hiding this comment.
We could skip using ts-node altogether for running tests like we did in the service bus project
There was a problem hiding this comment.
Can tackle this in a separate PR if we like?
|
@ramya-rao-a , @bterlson Does these changes also adds proxy for storage blob? We also connect to storage blob while establishing a connection to azure event hubs. |
|
@vaish1707 I believe storage should already support proxies as that service uses HTTP rather than AMQP. I'm not sure if there are docs for supporting this though. @XiaoningLiu can you help @vaish1707 find docs for supporting proxies in the storage client? Regarding support for proxies without this change landing, I wish I had a better answer. You could use the rhea library and talk AMQP directly to service bus, perhaps, but I think that would be a lot of work. |
|
Thanks for the reply. @bterlson is there any tentative date on when amqp proxy support will be available for eventhubprocessorhost for nodejs client? Also while adding the http proxy to storage blob . Is it going to be to append to the storage blob end point? |
|
The audit failure in CI is fixed by upgrading NYC in #31. |
|
@vaish1707 sorry I can't commit to a date, I'm just not sure. Proxy support for Storage should be a matter of replacing the underlying http agent with something like http-proxy-agent. You shouldn't need to change anything else other than how the client is configured initially. |
| import { | ||
| ApplicationTokenCredentials, DeviceTokenCredentials, UserTokenCredentials, MSITokenCredentials | ||
| } from "ms-rest-azure"; | ||
| } from "@azure/ms-rest-nodeauth"; |
There was a problem hiding this comment.
@bterlson When you tested Service Bus by pointing the amqp-common dependency to your git branch, were you able to run any of the examples like interactiveLogin, servicePrincipalLogin or the test on auth without making any changes?
There was a problem hiding this comment.
@ramya-rao-a I didn't try the samples. I'll report here with my findings, though I may need your help getting the AD side set up properly.
|
@ramya-rao-a ,@bterlson until the proxy support is available for the eventprocessorhost . We tried an alternative solution to open up the firewall for the ports 5671 and 5672 over TCP . We are still facing issues evening after opening up those ports over TCP. Also for storage blob we have opened up 443 and 80 over TCP.Are we missing something here? Can you please help on this? |
|
@vaish1707 would you mind opening a separate issue to discuss the issues you are running into? You can file an issue in the https://github.com/azure/azure-sdk-for-js repo and tag us in it! |
|
@alexandrudima, https://github.com/Azure/azure-event-hubs-node/issues/210 was logged by @vaish1707 @vaish1707 Let's have this discussion in the original issue you logged, I'll try to loop in the Event Hubs service team to get their insight |
The previous commits depended on rhea getting an updated package.json.
|
Now rebased and ready to merge once tests pass. FWIW, the only diff between the current new-msrest commit and the non-rebased commit (b387a88) is the NYC change to package.json: git diff new-msrest bterlson/new-msrest -- package.json
diff --git a/package.json b/package.json
index ea188c5..06ed70e 100644
--- a/package.json
+++ b/package.json
@@ -53,7 +53,7 @@
"karma-mocha": "^1.3.0",
"mocha": "^5.2.0",
"mocha-junit-reporter": "^1.18.0",
- "nyc": "^13.3.0",
+ "nyc": "^12.0.2",
"rhea": "^0.3.9",
"rhea-promise": "^0.1.13",
"rimraf": "^2.6.2", |
This PR implements support for web sockets. This is required to enable AMQP support in the browser and to enable proxying support for Node.js.
amqp-common now uses the template build process. While I wouldn't expect this to be distributed separately from its dependencies (for now), this build process ensures the library can be built for the browser by dependents.
This works by adding some options to ConnectionContextBase#create:
webSocket, a reference to a WebSocket constructor (e.g.WebSocketin the browser, orrequire('ws')in node. Proxy support is enabled by applying the proxy config to the WebSocket prior to passing it in to this API.webSocketEndpointPath, the path component to append after the host and port to reach the websocket endpoint, e.g. "$servicebus/websocket" for service bus.Unfortunately, Rhea isn't super great in the browser - it depends on a number of very hefty node shims resulting in a fairly large bundle (~500KB). The most straight-forward way to enable this short-term is
rollup-plugin-node-builtinsbut unfortunately NPM audit warns about this module. Another approach is to manually map node modules to browser dependencies.Left to do:
Future work:
Related to: