Grasshopper script from a web

Hi everyone,

I have a Grasshopper script that I’d like to access it through a website and currently needs help and please be patient as I am a complete newbie when it comes to all of these web app, windows server things

What I have done
I have run this tutorial successfully on my local PC
Created EC2 using this,
also done this tutorial and this tutorial

Where I am at
Currently this is what shown up when I access my website
image
so I guess all steps above have been done correctly?

Where I need help
I guess the next step for me is to run the tutorial example (spiky thing) on my website before I go with my own script (because it has some customized components which I have not installed on this VM Rhino) and I feel so stupid not to know how to do this :frowning:

Anyone please…

Hi @user1986 ,

If I’m not wrong, you are trying to access your VM by entering the URL directly on your browser (in a similar way you did with your local server). This is the message you receive when trying this.

After setting up the VM, you must create a client to communicate with the rhino.compute server you’ve just deployed. The API Key you defined must be included in your request to get the response.

As a first try to know if everything was set correctly, you can use Hops. If you want to test the connection in the browser, you can use any of the examples McNeel has in the GitHub repository. This is a good one to start with:

Open the project using VSCode and spin up a server using the Live Server extension. You will be required to enter the rhino.compute URL and your API Key.

Once you get your hands dirty with these examples, I also recommend visiting the AppServer project, an intermediate server between your client and rhino.compute which offers you extra features like storing Grasshopper definitions.

Kind regards,

2 Likes

Hi Pedro,

Thank you for your reply. Unfortunately none of this works for me.

[Edit] So I found the issue, I created another VM and Hop works just fine, until I assigned elastic IP address to the VM and it stops working. Any ideas why or what I have done wrong?

Update:

Hops now works - It does not work whileI remote into VM

The app server works. However it is really slow. It takes minutes for “the spiky thing” example to return a result. Is this because of the t2micro instance? What would be the recommended set up for Rhino?

Assume I get a new VM that works (because I rarely get a hold of anyone here). What next? I do have a website and have configured A record to this VM as well as set up a valid SSL certificate using win-acme like the tutorial. If I go to the website it still says the API Key was not provided. Which is okay, I know it has not been set up yet. But how and where do I start from?

@user1986 I’ll try to shed a little light as to what I think is going on. Firstly, you reported that you were getting an error saying API Key was not provided. You typically get this error when the Rhino.Compute server receives a request and it’s missing some information in the header of that request that provides some measure of authentication. This feature is included so that the Rhino.Compute server knows that the request is coming from you (or a trusted source) and not something else (which may or may not be malicious). When you first created your VM instance and ran the bootstrap script, it asked you for an API Key. This can be any text value that you want… it just needs to be unique to you. This value is stored on the VM as an environment variable. When the Rhino.Compute server receives a request, it first checks to see if there is a header in the request called RhinoComputeKey. If it’s not there, it returns the message that you see. If it is there, then it compares the value of the header against the environment variable stored on the VM. If those two values match, it then forwards your request onto the child process called Compute.Geometry to perform the calculation that the request is asking for.

So, if you’re using an app like Postman to send requests to your virtual machine, then you can include a parameter in the Header section (see image below). The key should be called RhinoComputeKey and the value is whatever API key you set as an environment variable on your VM.

Alternatively, if you’re using a client like Hops to send requests to your VM, then you can set the API key in the Hops preferences section. To get to this dialog, Open Grasshopper and go to File->Preferences->Solver.

Now, you mentioned that your app server is quite slow. As you pointed out, this is most likely due to the configuration of your virtual machine. The tutorial goes through and shows how to setup a VM using the free tier which is using the t2.micro. In my experience, this is just too slow to use for any meaningful work. We tend not to give too much guidance about machine configurations because it really depends on what the user is trying to achieve and how much resources their willing to expend. However, I typically use a t2.medium during testing phases of a project as that seems reasonably powerful for simple experiments. You can then go up from their as your project demands.

Does that help?

1 Like

Hi Andy,

Thank you for your reply. I will try t2.medium as you suggested!
For Rhino compute itself, I actually managed to get a bit further since my last comment and please allow me to explain:
After hops successfully make connection to the VM, I downloaded rhino app server and pushed it to Heroku. Using the domain created by Heroku, I can select “the spiky thing” example. However the display geometry does not show up and keep loading forever. Below is my config vars from Heroku with VM elastic IP address and API key from the environment variable table (which is confirmed correct by Hops)
[EDIT]: I just realized it is RhinoComputeKey instead of RHINO_COMPUTE_KEY like in the tutorial and have corrected this but still no luck.
I am using the https that Heroku provided for my app, do I need to set up Internet Information Services Manager on the VM to this address? I tried but I don’t think it takes https format.

Hello. Can you please check the browser console and paste any errors you are seeing here.