As someone somewhat familiar with the Go runtime but not with your exact 
use case, I'd like to help, but I'm wondering if you could provide some 
more concrete specification of the following from your post, in terms of 
code or logs: 

While porting my app from the Classic App Engine I was facing an issue with 
> the request context (which now "skips" the default HTTP load balancer and 
> goes straight to my MVM(gce) node).
>
 

> I was getting an error ("appengine: NewContext passed an unknown 
> http.Request").
>
 

> To overcome my need for datastore/logging/other App Engine facilities I 
> used context.BackgroundContext() everywhere and it seemed to work well for 
> the datastore/urlfetch/etc..


This might help me to reproduce your situation and attempt different 
solutions. 

As to your numbered questions, here are my first responses:

1. Are you talking about "Network Loadbalancing 
<https://cloud.google.com/compute/docs/load-balancing/network/>" or the GCE 
"Http Load balancer 
<https://cloud.google.com/container-engine/docs/tutorials/http-balancer>", 
and could you clarify again what kind of errors you observed when 
attempting this? What is meant by context "skipping"?

2. Do you notice that you're receiving X-Appengine-* headers? If so, you 
can certainly use them. If you attempt to add them to requests, do you 
notice if they're stripped? If they are, it won't work, if they aren't, it 
will. Although this is a quite empirical way to proceed, and if something 
isn't explicitly documented, you should file a Public Issue Tracker feature 
request <http://code.google.com/p/google-appengine/issues/list> to have the 
behaviour defined. 

3. Your log lines are all piling up under one /_ah/background entry, as far 
as I can tell. You could use the Logging API 
<https://cloud.google.com/logging/docs/api/tasks/creating-logs> to write 
logs, and see if that shows up properly. Another option is logging to a 
BigQuery or SQL table. The final, most trivial answer, is to figure out how 
to get request logging to work without this BackgroundContext which seems 
to flatten all its logs into one expando in the Developers Console UI (if 
I'm understanding you correctly, again, it seems like this is what you're 
reporting).

4.  A better approach could only be found through further investigation, if 
it exists. I'm optimistic that a better approach is out there, it would 
just take more thought.

On Sunday, December 20, 2015 at 11:17:12 AM UTC-5, John Smith wrote:
>
> *TL;DR: *Need to use WebSockets on AE. Only works on MVM. NewContext 
> fails, BackgroundContext works. Logs are polluted & disorganized 
> (/_ah/background)
>
> Hey,
>
> I would like to communicate with my App Engine app over WebSockets.
> I have found that the Java library has an official (github) example of 
> using WebSockets under the Managed VMs framework,
> after browsing the implementation I noticed that it queries the internally 
> exposed metadata service to get the external IP of the machine and 
> redirects the client to it.
>
> However I expect my application to receive more traffic than a single 
> server would handle and so I need a load-balanced solution (cannot relay on 
> a single static-IP)
> so I've looked into App Engine's "Network Load Balancer" and after an hour 
> (and 
> a long deploy time) I was up and running with now my domain set to the 
> load balancer's static IP.
>
> Now is a good time to note that I use the Go standard runtime.
> While porting my app from the Classic App Engine I was facing an issue 
> with the request context (which now "skips" the default HTTP load balancer 
> and goes straight to my MVM(gce) node).
> I was getting an error ("appengine: NewContext passed an unknown 
> http.Request").
> To overcome my need for datastore/logging/other App Engine facilities I 
> used context.BackgroundContext() everywhere and it seemed to work well for 
> the datastore/urlfetch/etc..
>
> Everything worked but the logging facility which was polluting my logs 
> with empty "/_ah/background" lines and everything else was multiplexed into 
> a single huge "/_ah/background" entry.
> This makes it very difficult to debug or monitor my application.
>
> I have browsed the google.golang.org/appengine package and tried to split 
> the log lines to no avail.
>
>
> My questions are:
> 1) Can I use the classic App Engine/default http load balancer/custom http 
> load balancer to service my WebSocket requests?
> 2) Can I, with my current solution, get the X-AppEngine-* headers?
> 3) How could I, with my current solution, split the log lines to per 
> request entries (very like the classic app engine logs)
> 4) Is this the right approach?
>
> Thanks.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/64695383-c098-47a6-ae54-9000a29ce19e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to