I am looking to integrate ngx-socket-io into my Angular application. I utilize Bazel for running my Angular dev-server.
Unfortunately, it seems that ngx-socket-io
does not function properly with the ts_devserver
by default. Upon checking the browser console, I encountered the following error:
Uncaught TypeError: XMLHttpRequest is not a constructor
at ts_scripts.js?v=1587802098203:16776
at Object.23.../transport (ts_scripts.js?v=1587802098203:16780)
at o (ts_scripts.js?v=1587802098203:11783)
This issue appears to be related to xmlhttprequest-ssl, which is a dependency of engine.io-client and is required by ngx-socket-io
. However, this problem specifically arises when using the ts_devserver. Operating the Angular app in production mode works perfectly fine.
Minimal Reproduction
To replicate the issue, you can follow these steps: https://github.com/flolu/bazel-socketio-issue
Simply run yarn install
followed by yarn dev
(this will trigger the error in the browser console @ http://localhost:4200).
Additionally, please note that running yarn prod
@ http://localhost:8080 functions without any issues!
Edit 1
There currently appears to be an additional complication on Windows. Therefore, the example repository can only be tested on Mac or Linux systems.