Right now, the agent assumes that the backend server is connected to over HTTP (without SSL). That is normally the case since the agent is usually run on the same machine as the backend, but there is no reason to force that to be the case.
Ideally, we would allow the user to specify a full URL for the backend when starting the agent, and if that URL includes a scheme then we would honor it.
This would require changing (at least) the code here that hard-codes the scheme as "http"