Network connection from audio plugin?

I’m trying to open a network connection between my audio plugin and a web server (for one-time license activation). Right now I’m using a local web stack (MAMP) for testing.

I’m using WebInputStream as follows:

WebInputStream inputStream(URL("http://localhost:8888/test.php").withPOSTData(JSON::toString(data)), true);
var response = JSON::parse(inputStream.readString());

But my PHP script never receives the request. I’ve of course double checked that the URL works in a web browser, and I also successfully tested the PHP script using Postman.

I tried calling ìnputStream.connect(), but it doesn’t make any difference.
I’m on Mac, so I also enabled the com.apple.security.network.client entitlement.

What else could I be doing wrong?

Perhaps http is being blocked by AppTransportSecurity, you’ll see something in the debug output to that effect if so.

You need https. You can get a free cert from https://letsencrypt.org/

Thanks, where can I find the debug output?

Alright, thanks for that! I have a cert already on the production site, so I guess I just need to figure out how to use one locally for testing?

For a local development environment, try mkcert: https://github.com/FiloSottile/mkcert

mkcert automatically creates and installs a local CA in the system root store, and generates locally-trusted certificates. mkcert does not automatically configure servers to use the certificates, though, that’s up to you.

The debug output you can see when starting the DAW from XCode, you will need to edit the scheme for the current target:

image

and then change the Executable from None to Ask on Launch.

After that when you press the “play” button in XCode (or use Cmd-R) you will be asked which program you want to start, choose your DAW and then you’ll see the debug output at the bottom of XCode window, you may need to activate the console:

Add your plugin to the DAW as normal and you’ll see any debug from it (you might also see a load of other stuff from the DAW itself which you can ignore).

Thank you!

I managed to create a self-signed certificate for MAMP by following instructions here. And as soon as I switched to https, everything started working as expected! :smiley:

1 Like

Thanks for the detailed instructions on how to see the debug output!

I have always started the DAW separately and then attached to it from Xcode while running, that explains why I never saw it before. :smiley:

1 Like