GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — websocket · Issue #473 · GoogleCloudPlatform/java-docs-samples Closed DescriptionwebsocketI'm working on below sample code, how to use websockets on Google App Engine Flexible Environment with java. Sorry, It's working now, forgot to add Metadata-Flavor header in the requeststill, it's worth having spring-websocket sample code, who want to use jGAE with spring websocket Sample CodeFirewall rule app.yaml private static final int DEFAULT_PORT = 65080; private static final String NETWORK_INTERFACE_METADATA_URL = "http://metadata.google.internal/computeMetadata/v1/instance/network-interfaces/0/access-configs/0/" + "external-ip"; private String getHostname() throws IOException { String hostname = "localhost"; // if (SystemProperty.environment.value().equals(SystemProperty.Environment.Value.Production)) { URL url = new URL(NETWORK_INTERFACE_METADATA_URL); HttpURLConnection httpUrlConnection = (HttpURLConnection) url.openConnection(); httpUrlConnection.setRequestProperty("Metadata-Flavor", "Google"); // httpUrlConnection.setRequestProperty("X-Google-Metadata-Request", "true"); InputStream in = httpUrlConnection.getInputStream(); BufferedReader reader = new BufferedReader(new InputStreamReader(in)); String result, line = reader.readLine(); result = line; while ((line = reader.readLine()) != null) { result += line; } hostname = result; // } return hostname; } /** * @return a Websocket URL of this server. * @throws IOException when failed to get the external IP address from the metadata server. */ public String getWebSocketURL() throws IOException { return "ws://" + getHostname() + ":" + this.getPort() + "/"; } RefActivity
|
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |