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

Run on Node #20

Closed
ghost opened this issue Apr 19, 2017 · 8 comments
Closed

Run on Node #20

ghost opened this issue Apr 19, 2017 · 8 comments

Comments

@ghost
Copy link

ghost commented Apr 19, 2017

Any way to configure it to run on node? https://github.com/reactivex/rxjs/#nodejs-usage

@billba
Copy link
Member

billba commented Apr 19, 2017

Any reason to think it doesn't? I have heard from folks who have it running on servers.

@ghost
Copy link
Author

ghost commented Apr 20, 2017

I tried to use it on Node and it goes only up-to 'Connecting'. Debugging showed that it throws

Error: XMLHttpRequest is not supported by your browser
    at getXMLHttpRequest (..\node_modules\rxjs\observable\dom\AjaxObservable.js:45:19)
    at Object.createXHR (..\node_modules\rxjs\observable\dom\AjaxObservable.js:93:71)
    at Object.tryCatcher (..\node_modules\rxjs\util\tryCatch.js:6:31)
    at AjaxSubscriber.send (..\node_modules\rxjs\observable\dom\AjaxObservable.js:191:50)
    at new AjaxSubscriber (..\node_modules\rxjs\observable\dom\AjaxObservable.js:180:14)
    at AjaxObservable._subscribe (..\node_modules\rxjs\observable\dom\AjaxObservable.js:115:16)
    at AjaxObservable.Observable._trySubscribe (..\node_modules\rxjs\Observable.js:57:25)
    at AjaxObservable.Observable.subscribe (..\node_modules\rxjs\Observable.js:45:27)
    at MapOperator.call (..\node_modules\rxjs\operator\map.js:54:23)
    at Observable.subscribe (..\node_modules\rxjs\Observable.js:42:22)

The hack from rjxs worked but I wonder if there is an out-of-box way?

global.XMLHttpRequest = require("xhr2");

@billba
Copy link
Member

billba commented Apr 20, 2017

Nope, sounds like you've found a good working solution. Would love a PR to the README to help others with this problem.

@poul-kg
Copy link

poul-kg commented Jun 19, 2017

@sunseaandpalms Hi, can you explain how you applied rxjs fix you mentioned? Do you have working DirectLine under NodeJS?

@poul-kg
Copy link

poul-kg commented Jun 19, 2017

I've added
global.XMLHttpRequest = require("xhr2");
to the top of my main index.js file, but still DirectLine connection do not work

@poul-kg
Copy link

poul-kg commented Jun 19, 2017

Ok, looks like adding global.XMLHttpRequest = require("xhr2"); to the top of the main .js file, can solve this issue. I wasn't sending any messages, that's why connection status was not updating.

@danmarshall
Copy link
Contributor

Would be good to know if the xhr2 trick still functions back in DOM-land. Perhaps then we can have it in master?

@billba
Copy link
Member

billba commented Jun 19, 2017

I'd hate to do that, because that would make the client build bigger.

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

No branches or pull requests

3 participants