Search Unity

Webservice Windows build endless process from batch

Discussion in 'Windows' started by ben3d, Sep 20, 2019.

  1. ben3d

    ben3d

    Joined:
    May 19, 2014
    Posts:
    24
    Hello,
    I'm stuck with an issue that i havn't been able to solve, so i hope someone will be able to help me.

    I set up a webservice on windows with IIS. It works great until i tried to use Unity. Let me explain what it does :

    1 - The webservice call a batch file and wait for the process to end.
    2 - The batch file call an .exe file that i have made. It open a 3d file format, draw it, take a picture and then save the picture on hard drive. I used OpenGL to do this.
    3 - The process has end, so the webservice open the image and send it to the user.

    This is my initial setup and it works great, no problem at all. Then i wanted to update the rendering process to get a better quality image. I created a new .exe file from Unity to do so, a windows standalone build.

    Here is my issue, when i replace OpenGL exe file by Unity, the process launched by the batch file never end. For test purpose i created another standalone build with nothing inside, only one script attached to the camera that write a file on the hdd then quit. But same endless process. Both Unity build works fine when I launch them from batch file by double clicking on it. The probleme seem to be when the webservice launch the batch file.

    The batch file is launch with administrator's right by the webservice else even the opengl build cannot be launched.
    The batch file launch Unity standalone build with argument "-batchmode". Here is the line in batch file :
    Code (batch):
    1. "C:\WebService\Renderer.exe" 22 81 130 0 -batchmode
    Tested with Unity 2017.4.30f1 and 2019.2.3f1. I also tested "Server Build" option in Build Settings but no change.

    Any help is welcome, thank you :)
     
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    6,540
    Hey, could you capture a dump file of it being hanged via the task manager (right click on the process in Details tab and press "Create dump file")?
     
  3. ben3d

    ben3d

    Joined:
    May 19, 2014
    Posts:
    24
    Hello.
    The file was too large to be uploaded here, so i uploaded it here : https://gofile.io/?c=vbO088
    I didn't see anything interesting inside, but it's the first time i read a DMP file :)
    Thanks for your help. I hope we'll find where the problem come from.
    Regards,
     
  4. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    6,540
    So I looked at the dump and it doesn't look like the process is stuck or deadlocked. Did you try debugging your code to see perhaps an exception gets thrown somewhere and Application.Quit fails for some reason?
     
  5. ben3d

    ben3d

    Joined:
    May 19, 2014
    Posts:
    24
    I tried yes. But nothing wrong happened. The standalone build works fine when i'm using it manually. But when launched by IIS, the application seems to start as it appear in process list. But the first line of code is to write a text file that is never created. Maybe an another parameter than -batchmode requiered ? Or some options to check in project settings to be able to use standalone as headless server process ?
    I think it come from Unity since other program that i'm using like this works fine when called by IIS. Is it possible to use Unity Standalone build like this, or it has some restriction ?
     
  6. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    6,540
    Does your script get invoked at all? Do breakpoints hit in the C# debugger? Could be a weird permission issue as AFAIK IIS launches apps on as a different user.
     
  7. ben3d

    ben3d

    Joined:
    May 19, 2014
    Posts:
    24
    I believe the script not invoked since there are no file created. C# debugger ? I'm not sure what you are referring at. Do you mean in editor ?
    I gave an administrator user to IIS app pool with full right and set permission of folder where app is stored to global. I use the same folder for other app that are launch by IIS. I don't know what other permission I could give.
     
  8. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    6,540
  9. ben3d

    ben3d

    Joined:
    May 19, 2014
    Posts:
    24
    Thank you. If there was a problem in the code, didn't unity player shouldn't work as well ? I will try the code debugging and see what happening :)
     
  10. ben3d

    ben3d

    Joined:
    May 19, 2014
    Posts:
    24
    Good news.
    It's finally working. It seems that a Unity standalone player require more right than an other executable, so no choice. I know it is a bad idea but i had to configure IIS with full right to be able to launch it. An user administrator was not enough so I had to upgrade it to system administrator. I didn't know that there even was a difference.
    In any event, it's now working. so thank you :)