Chaoses-Ib / ComfyScript

A Python frontend and library for ComfyUI
https://discord.gg/arqJbtEg7w
MIT License
422 stars 24 forks source link

No issue, but thought you may be able to help me. Trying to run ComfyUI on 8188 and 8190. API always goes to 8188! #72

Closed jdc4429 closed 1 month ago

jdc4429 commented 1 month ago

Since you made this app, i figure you probably know how I can make this work. I run two installations of ComfyUI.. One on port 8188 and one on port 8190. I run a website (https://AiImageCentral.com) and I setup the RTX 2070 to do SDXL Lightning image generations on port 8188. I setup a new webpage to start offering Flux on my P40 which is running another installation of Flux on port 8190.

I put port 8190 in the python script and if I run from command line it works through 8190 using the second card but as soon as I use any method through the website (using .bat file to execute or python file) it sends the API request to 8188! WHY!

For the life of me, I have tried many AI bots to try and fix this but no matter what I try it never goes to 8190 when I click the button on the website... How can I force the API to listen to me and use port 8190 like I put in the scripts???

Chaoses-Ib commented 1 month ago

as soon as I use any method through the website (using .bat file to execute or python file) it sends the API request to 8188! WHY!

Have you specify the port in the script to execute? e.g.

load("http://127.0.0.1:8190")
jdc4429 commented 1 month ago

Yes, of course. It just ignores it and goes to 8188 (My RTX 2070) when I want it to go to port 8190 where my P40 is.

Chaoses-Ib commented 1 month ago

I can't find any relevant issue in the code. 8188 will only be used if there is no argument (or the argument is None) for load().

How do you execute the script? python xxx.py? or import in the same process as the website server? Could you show the code of the server, or make a minimal reproducible example?

jdc4429 commented 1 month ago

Here is the code for submitting..

if (isset($_POST['submit_first'])) {
    $width = (int) 1920;
    $height = (int) 1080;
    $data = array('userip' => $userIP,'rprompt' => $rprompt,'nprompt' => $nprompt,'smodel' => $smodel,'width' => $width,'height' => $height,'cfg' => $cfg,'steps' => $steps,'sampler_name' => $sampler);
    $jsonData = json_encode($data, JSON_PRETTY_PRINT);
    $file = 'parameters.json';
    file_put_contents($file, $jsonData);
    $command = 'C:\inetpub\wwwroot\python\python.exe c:\\inetpub\\wwwroot\\websockets_flux-cli.py $rprompt >> logfile 2>&1';
    exec($command);
    header("Location: " . $_SERVER['PHP_SELF']); // Redirect to the current page to prevent resubmission

I have tried multiple ways through a python script, php, or bat file. No matter what I do it always goes to 8188.

I even tried creating a text file and have my chat server look for if the file exists and then have my chat server execute the command. It still goes to 8188 and it's not even going through the website. But if I start a cmd prompt and type the command manually it works just fine and goes to 8190. It's so annoying.

I have attached server code. I thought since this was not going through the website it would work.

wss-server-js.txt

Chaoses-Ib commented 1 month ago

That's really weird. The only possible reason I can think of is that your servers have different environment variables from the cmd prompt, like using different Python venv, and that somehow causes the problem.

Could you use the server to run the following script and upload the output?

from comfy_script.runtime import *
load("http://127.0.0.1:8190")
from comfy_script.runtime.nodes import *

import comfy_script.client
print(comfy_script.client.client.base_url)

import sys
print(sys.base_prefix, sys.base_exec_prefix, sys.prefix, sys.exec_prefix, sys.path, sep='\n')

It should give output like this normally:

Nodes: 205
http://127.0.0.1:8190/
C:\ProgramData\Miniconda3\envs\py310
C:\ProgramData\Miniconda3\envs\py310
D:\venv
D:\venv
[...
jdc4429 commented 1 month ago

I think it can work with me just creating a file to read the prompt and trigger the bat file. I just need to fix the errors. I manually created the trigger file and it did work so I just need to get the stupid webserver to do it right and I can bypass all the issues this way I think.

jdc4429 commented 1 month ago

I need more details on running the script. How do I run it with the server?

jdc4429 commented 1 month ago

I got it working the way I stated I was using to get around the issue. Flux now added.