coreybutler / fenix

A simple and visual static web server with collaboration features.
https://preview.fenixwebserver.com
GNU General Public License v3.0
1.65k stars 135 forks source link

"Force Port" dialog option bugged(?) in 3.0.0-rc.13 #119

Open gps1784 opened 4 years ago

gps1784 commented 4 years ago

As best as I can tell, in the v2.0 UI, I am able to assign multiple applications to port 80. This is fine, as I am often only running one of these servers at a time. The v3.0 UI does not allow me to do this at all. I appreciate that Fenix warns me, but I'd like to sidestep this behavior, so that it acts as a warning instead of an outright error. Clearly, this error is the intended behavior in v3.0, as this is a new feature. Any chance of adding a "I know what I'm doing, and why I'm doing it" button to that dialog, so I can have my cake and eat it, too? (last second edit) I was getting ready to submit this and was double checking the behavior in Fenix. One time, I was able to get a dialog that said "force port" but I don't seem to be able to make that happen again. What caused the dialog to show up this one time? I'm not really sure.

To recreate this error: Create two servers, try to assign them to the same port. This dialog gives options to "Continue Using [port number]" and "Use Next Available", but no option to "Force Port [port number]"

System Information: Windows 10.0.18362, Fenix version 3.0.0-rc.13

Any thoughts? Is this a bug, or acting as intended?

(scatterbrained edit) If I have the time, I'd be willing to poke around and even supply a PR if you can point me in the right direction here. Thanks for your work, really liking 3.0 so far!

gps1784 commented 4 years ago

Just tried it again at bootup, before having started any servers, and it allowed me to share the port between servers while they were both off. Something here is not working as intended.

coreybutler commented 4 years ago

In Fenix 2, you can specify the same port for more than one server, but it is not possible to run more than one server on a port at the same time.

In Fenix 3, if you have a running server and attempt to create another server on the same port, it responds as you've experienced. If the other server is not running, it will allow you to use the same port. Only one of the servers will start at a time.

This was a design choice in Fenix 3, mostly because I kept getting requests to not allow the same port by default.

If there were a "force port" option, it would shut the running server down first, or it would not start the new server. I'm not sure which of those would make sense to the community at large.

Technically speaking, it is sort of possible to run more than one server at the same time using multiplexing (essentially a proxy), but we don't have that in Fenix at the moment. I built it for another product, but it's in a different programming language... whole different stack, actually :-)

I truly appreciate the offer to submit a PR. Unfortunately, we haven't released the source for Fenix 3 yet. The build process is pretty substantial, so I'm not sure if/when that will happen.

I'm going to close this as "wontfix" and add an enhancement request flag to this issue. I will not lock the issue, so feel free to keep conversing (this goes to anyone). I'm only closing it so we can track bugs effectively, and this is not a bug.

gps1784 commented 4 years ago

If you don't mind, I'm going to try again, taking it from the top. I don't think I was explaining the issue well last night.

In Fenix 3, you can assign two (or more) web servers to share a port, with a few exceptions.

Example 1: Halt all Fenix servers. Close any Fenix sessions. Open a new session, with no servers running. Assign two or more Fenix servers to the same port. Fenix allows this, as expected :heavy_check_mark:

Example 2: Halt all Fenix servers. Close any Fenix sessions. Open a new session, with no servers running. Start a server and while running, assign a second server to the same port. Fenix does not allow this, as expected :heavy_check_mark:

Example 3: Halt all Fenix servers. Close any Fenix sessions. Open a new session, with no servers running. Start a server, then stop the server. Assign a second server to the same port. Fenix does not allow this, which is not the behavior I would expect. :heavy_exclamation_mark: It seems to remember that there was a port open, even if the port is no longer open. If I want to add a new project, I have to stop all my servers and follow the procedure outlined in Example 1. Is this persistent caching expected?

I'm still not quite sure how I triggered a dialog with a "Force Port 80" option last night. If I can make a test case that causes this dialog consistently, I'll let you know.

I want to emphasize, I really like the feature that keeps me from accidentally trampling other servers' ports, it just seems overprotective of ports that had been in use, but are not currently.

coreybutler commented 4 years ago

Ah, I understand now. I'll take a look at the code responsible for tracking the ports.

Just to clarify, is there a remote chance some other process has opened anything on port 80 (or whichever port you want to duplicate) outside of Fenix? I know this is a very unlikely case, but I still need to ask. Fenix uses porthog to identify port conflicts. If it recognizes a port as in-use, Fenix will behave as you've experienced. I suspect the port caching is the true culprit, and knowing whether there is a chance something else consumes the port would help rule out any porthog-related conflicts.