Kitware / web-project-templates

This repository try to gather various web project templates based on vue, vtk.js, paraviewweb...
26 stars 10 forks source link

How to use npm run serve with external render server #14

Closed phcerdan closed 3 years ago

phcerdan commented 3 years ago

Hi @jourdain, sorry to open issues like crazy, I find it easier for learning purposes (for me and others) to ask out loud and then close it fast. But please don't feel pressure, if you cannot answer, I might find the solution elsewhere and close it myself! PS: Ne me déteste pas!

If I run npm run serve & and then the paraview server in the same port, I got a twisted error (that I think makes sense).

pvpython ./server/pvpython/pvw-server.py --virtual-env ~/.virtualenvs/my_env --port 8080

Traceback (most recent call last):
  File ".virtualenvs/my_env/lib/python3.9/site-packages/twisted/internet/tcp.py", line 1361, in startListening
    skt.bind(addr)
OSError: [Errno 98] Address already in use

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "src/vue-vtkjs-pvw-template/./server/pvpython/pvw-server.py", line 130, in <module>
    server.start_webserver(options=args, protocol=_Server)
  File ".virtualenvs/my_env/lib/python3.9/site-packages/wslink/server.py", line 216, in start_webserver
    reactor.listenTCP(options.port, site)
  File ".virtualenvs/my_env/lib/python3.9/site-packages/twisted/internet/posixbase.py", line 495, in listenTCP
    p.startListening()
  File ".virtualenvs/my_env/lib/python3.9/site-packages/twisted/internet/tcp.py", line 1363, in startListening
    raise CannotListenError(self.interface, self.port, le)
twisted.internet.error.CannotListenError: Couldn't listen on any:8082: [Errno 98] Address already in use.

If I run the paraview server in another port, for example --port 1234, the client doesn't show the render in http://localhost:8080/

Peek 2021-02-18 17-55

It works if I npm run build, and then point to the dist folder for the paraview server.

npm run build and pvpython ./server/pvpython/pvw-server.py --virtual-env ~/.virtualenvs/my_env --port 1234 --content ./dist

Is there a way to use npm run serve with the external rendering?

jourdain commented 3 years ago

No worries...

1) First of all you can't have 2 processes running on the same port. 2) In real life, you will get the built web client served by either the pvpython process (--content) or via apache/nginx. 3) In that current example we assume the ws server will run on 1234 because of that

phcerdan commented 3 years ago

Thanks @jourdain , I am able to use npm run serve & when localhost is 8080, and the server is in port 1234.

https://github.com/Kitware/web-project-templates/blob/master/vue-vtkjs-pvw-template/src/components/core/App/script.js#L73-L76

Thanks!