Fix websocket building on non standard ports - closes #2952#2953
Fix websocket building on non standard ports - closes #2952#2953drosetti merged 6 commits intointelowlproject:developfrom
Conversation
Fix connection issue when intelowl is on nonstandard port
|
Hi @faux-eccles, thanks for your contribution! Next time request a review to me, in this way i'll be notified about your pr. I tried it on my pc, but I can see in the network tab the ws request is stucked in pending status with you change |
|
@drosetti Ah my bad, the screenshot was of the issue not the fix. Should have put it only on the issue ticket, and only had the fix in the PR. |
|
Don't worry about the screenshot, it's not a big deal. Even if it's correct the problem remains: in my env the websocket cannot connect from the frontend to the backend. Maybe I have to change ports in the container ? |
|
My change should be connecting to the same port that the page is serving from so if you can load the page it should connect. That being said in my environment the ports are changed in the container, I've shared a screenshot of my setup in the linked issue |
|
This pull request has been marked as stale because it has had no activity for 10 days. If you are still working on this, please provide some updates or it will be closed in 5 days. |
|
@faux-eccles Ok I changed the port on docker and it worked on standard port (80), but there is another problem: the UI environment is on port 3001, if you want to work on frontend this changes makes the websocket fail. I'd like to discuss with you a possible solution for this problem. I prefer to avoid to edit the docker conf because some contributors work quite often on the frontend and change it every time is quite annoying imho. |
|
This pull request has been marked as stale because it has had no activity for 10 days. If you are still working on this, please provide some updates or it will be closed in 5 days. |
|
@faux-eccles any updates on this? |
|
Changing the port in docker was a local config to run the service in my environment as port 80 is already in use and shouldn't be necessary for the fix itself. I don't have experience with hosting the UI separately to the backend service for developemnt which is what it sounds like @drosetti is doing. I think it would make sense to then dynamically build/set the port based on launch parameters. I can take a look to see what looks like. (also apologies for the slow responses, have just moved countries and in the middle of getting resituated) |
Looking into this a bit further this seems strange, my assumption is the npm proxy directive in package.json should be forwarding the requests along as with everything else. So in your environment hosting the react server on 3001, my changes should be connecting to localhost:3000/ws and NPM should forward the requests. I'll see if I can recreate locally |
|
Launching the npm dev server with the default configuration on this branch using the method outlined in the docs appears to be working as expected (besides some unrelated CORS errors that prevents me from actually submitting jobs to validate messages are coming through as the NPM server appears to just open a websocket connection regardless of the other end being available) Do you have the dev react app calling the api server directly and not via the npm proxy?
edit: Fixed the 403 errors by setting the environment variable |
|
I've updated the package.json and added a middleware configurations for the react-scripts so that the webpack proxy correctly handles websockets. This might fix the need for having websockets on different ports while developing.
|
|
This pull request has been marked as stale because it has had no activity for 10 days. If you are still working on this, please provide some updates or it will be closed in 5 days. |
|
This pull request has been closed because it had no updates in 15 days. If you're still working on this fell free to reopen. |
There was a problem hiding this comment.
Hi @faux-eccles thanks for your work and apologizes for my late response.
Everything work fine, thansk for your changes.
I noticed you use http-proxy-middleware. This library is available becase it's installed in the package-lock.json, but it's not listed in the dependencies in the package.json.
I ask you to add it as dependency in the second file I mentioned or, even better, if you could do the same thing but with the config of Axios in the initAxios file. It would be better because we don't have to add another dependency, but I'm not sure if it's possibile, you should check the Axios's doc and do this change in case it's possibile. In case it's too work or it's not supported from Axios the first option is fine
Edit: please use the pr review feature of github (on the top right), in this way I get a notification via email to review your work or it could be possible I forget to review your code
|
Not sure what you mean about moving the changes into Axios. This looks likes purely a frontend request client which is behaving normally. The proxyConfig I'm introducing should only be loaded by and effect the server side of the npm dev server instructing it how to forward requests |
… required for local development



Fix connection issue when intelowl is on nonstandard port
Description
Change the way the websocket address are built to ensure the hosts ports are being referenced. #2952.
Type of change
Please delete options that are not relevant.
Checklist
developdumpplugincommand and added it in the project as a data migration. ("How to share a plugin with the community")test_files.zipand you added the default tests for that mimetype in test_classes.py.FREE_TO_USE_ANALYZERSplaybook by following this guide.urlthat contains this information. This is required for Health Checks (HEAD HTTP requests)._monkeypatch()was used in its class to apply the necessary decorators.MockUpResponseof the_monkeypatch()method. This serves us to provide a valid sample for testing.DataModelfor the new analyzer following the documentation# This file is a part of IntelOwl https://github.com/intelowlproject/IntelOwl # See the file 'LICENSE' for copying permission.Black,Flake,Isort) gave 0 errors. If you have correctly installed pre-commit, it does these checks and adjustments on your behalf.testsfolder). All the tests (new and old ones) gave 0 errors.DeepSource,Django Doctorsor other third-party linters have triggered any alerts during the CI checks, I have solved those alerts.Important Rules