App Server error: net::ERR_ABORTED 405 (Method Not Allowed)

Hello! I setup the VM in Azure as describe here: Rhino - Deployment to Production Servers (rhino3d.com). The connection to Hops works fine, but when I try to run the app server, it fails.
First of all, I suspect I have to define env variables in my local PC → RHINO_COMPUTE_KEY, RHINO_COMPUTE_URL (used in the index.js), so i guess what happen in the demo is no longer correct (Will paste it directly in the code ~02:11:21) Rhino App Server - YouTube
When trying to run ‘spiky thing’ I’m getting some errors:
Any idea? Thanks!


VM rhino specs:
{
“rhino”: “7.28.23058.3001”,
“compute”: “1.0.0.0”,
“git_sha”: “6f5ae3e1”
}

Are you running appserver locally? A local appserver can only speak to a local Rhino.Compute instance and a remote appserver can only speak to a remote Rhino.Compute instance.

Summary: So, to run Hops (1) using VM computation, I just need to set the parameter URL and KEY in preference>solver. To execute the vscode or other application request and get the json (2) I need to run the appserver locally (npm run start). And finally, to use the js application (3), both appservers must be running (local and VM).

  1. Setup VM: I suspect it’s a new version and doesn’t match the video ( Rhino App Server - YouTube) but after following all the steps ( Rhino - Deploying to Production Servers (rhino3d.com)) the compute.geometry service is not displayed. → is it usual?

  2. Run Hops: install compute in the VM, define URL and KEY in grasshopper (local) and works.

  1. Request API: Define env variables RHINO_COMPUTE_URL/KEY in local machine. Start the appserver in local machine and return the resolved json. It works like a charm.
C:\Users\casas\OneDrive\compute.rhino3d.appserver>npm run start

> @mcneel/compute.rhino3d.appserver@0.1.11 start
> node ./src/bin/www

Started worker 1
RHINO_COMPUTE_URL: http://****/
Listening on port 3000
Go to viewer: http://localhost:3000/view
GET /solve/srf_kmeans.gh?int_resolution=30&int_dimension=30&num_x=0.5&num_y=0.5&int_k=6 200 884.433 ms - -

Sometimes this error occurs:

{
  "message": "Internal Server Error",
  "stack": "Error: Internal Server Error\n    at C:\\Users\\casas\\OneDrive\\compute.rhino3d.appserver\\src\\routes\\solve.js:152:15\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)"
}
  1. Run js app: I need to run both appservers (local and vm) to interact with the gh definition, right? Call from http://localhost:3000/examples/spikyThing/

When i am running boths app servers at the same time (vm and local) it works perfectly (did you refer to that? ‘A local appserver can only speak to a local Rhino.Compute instance and a remote appserver can only speak to a remote Rhino.Compute instance.’)

> @mcneel/compute.rhino3d.appserver@0.1.11 start
> node ./src/bin/www

Started worker 1
RHINO_COMPUTE_URL: http://*****/
Listening on port 3000
Go to viewer: http://localhost:3000/view
GET /examples/spikyThing/ 304 7.850 ms - -
GET /examples/spikyThing/script.js 304 2.397 ms - -
GET /examples/favicon/site.webmanifest 304 2.245 ms - -
GET /examples/favicon/favicon-32x32.png 304 2.945 ms - -      
POST /solve 200 561.313 ms - -

If both do not start, this error occurs:

GET /examples/spikyThing/ 304 1.793 ms - -
GET /examples/spikyThing/script.js 304 0.869 ms - -
GET /examples/favicon/favicon-32x32.png 304 0.999 ms - -
GET /examples/favicon/site.webmanifest 304 0.953 ms - -
Error: Internal Server Error
    at C:\Users\casas\OneDrive\compute.rhino3d.appserver\src\routes\solve.js:152:15
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
POST /solve 500 4177.648 ms - 249

And this is what rhino. Compute shows in the vm:

System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:3000
   at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)
   --- End of inner exception stack trace ---
   at System.Net.HttpWebRequest.GetResponse()
   at compute.geometry.GrasshopperDefinition.ArchiveFromUrl(String url) in /home/runner/work/compute.rhino3d/compute.rhino3d/src/compute.geometry/GrasshopperDefinition.cs:line 1067
   at compute.geometry.GrasshopperDefinition.FromUrl(String url, Boolean cache) in /home/runner/work/compute.rhino3d/compute.rhino3d/src/compute.geometry/GrasshopperDefinition.cs:line 93
   at compute.geometry.ResthopperEndpointsModule.GrasshopperSolveHelper(Schema input, String body, Stopwatch stopwatch) in /home/runner/work/compute.rhino3d/compute.rhino3d/src/compute.geometry/ResthopperEndpoints.cs:line 99
   at compute.geometry.ResthopperEndpointsModule.Grasshopper(NancyContext ctx) in /home/runner/work/compute.rhino3d/compute.rhino3d/src/compute.geometry/ResthopperEndpoints.cs:line 172
   at Nancy.Routing.Route.<>c__DisplayClass4.<Wrap>b__3(Object parameters, CancellationToken context)
CG 80 [14:00:45 INF] 170.253.22.152 - [2023-05-01T14:00:45.2363352+00:00] "POST /grasshopper HTTP/1.1" 500 -

It seems like you got some things working. If you have further questions (it was not clear from your last post) please let us know.

@little_grasshopper I’m running into the same problem as you did a few months ago with running the appserver…

Error: Internal Server Error
    at C:\Users\xxxxx\app\src\routes\solve.js:152:15
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    POST /solve 500 8276.577 ms - 258

Did you managed to fixed this issue? If so, would you mind sharing your insights? Or perhaps @fraguada or @AndyPayne @will you have an idea what this could be about? Thanks!

Have you tried the latest src? I did some work on it not long ago that might have affected this.

yes, trying the latest from the repo. Could you point me to those changes there?

unfortunately the error doesn’t give me enough info to know what is causing the issue. What are the logs from compute?

There are no logs on the VM where compute is installed as the request doesn’t seem reach it.

You can replicate this behavior locally by running the latest appserver locally and pointing to a remote compute server (by setting the remote URL and keys in the environment variables in you own PC). The same behavior is displayed when the appserver is deployed elsewhere.

What about local appserver to local compute server? You should get logs there.

Oddly enough, when pointing to local compute everything runs smoothly. Are you able to replicate this?