framework icon indicating copy to clipboard operation
framework copied to clipboard

set Port

Open SleepShadowWeb opened this issue 10 years ago • 7 comments

  • framework.route(url, fn, [flags]);
  • framework.websocket(url, fn, [options]);

You recommend:

options.ip = '127.0.0.1'; options.port = '1234'; require('total.js').http('release', options);

How to set port for each call?

F.route('/command/', use_command, {flags: ["post"], timeout: 10000}); F.websocket('/', socket_modules, ['json', F.config.site_url]);

Now "route" and "websocket" use port=1234

I want use different port fot each call:

For Examle: F.route('/command/1/', use_command1, .... => port=1111 F.route('/command/2/', use_command2, .... => port=2222 F.websocket('/', socket_modules, ..... =>port=5555

How to do it?

SleepShadowWeb avatar Mar 21 '16 02:03 SleepShadowWeb

Hi @SleepShadowWeb, this is not possible. I know what you want. A web server with the port is initialized when is the framework started. So you can't change the port.

Only way how to handle it: run multiple apps on different ports. Can you write me why do you need this?

Thanks.

petersirka avatar Mar 21 '16 06:03 petersirka

Simple reason:

  1. query processing third-party services running on its ports + your code works on the other ports
  2. maybe division security rights

SleepShadowWeb avatar Mar 21 '16 18:03 SleepShadowWeb

I understand what you want but this is not possible. As I wrote, the framework runs on the one port and you can't change this port when is the framework running. You have to create master process with child total.js applications which they will run on different ports.

Sorry :-(

petersirka avatar Mar 21 '16 20:03 petersirka

I understood it all. you just wrote: Can you write me why do you need this? so I said)

Thanks for the answer!

SleepShadowWeb avatar Mar 21 '16 22:03 SleepShadowWeb

Yes, you're right. Thanks.

petersirka avatar Mar 22 '16 06:03 petersirka

"The IP address and the PORT is already in use. You must change the PORT's number or IP address."

this is the error message it gives me. i was just testing projects dowloaded from github...

i started the first project but i cannot try the second one because the port and the ip adress are already in use... help please

Will-create avatar Jun 15 '20 17:06 Will-create

Stop the first app and the second will work or change the default port in the config. It's all in the documentation https://docs.totaljs.com/latest/en.html#api~FrameworkConfiguration

molda avatar Jun 15 '20 17:06 molda