cesium + node-webkit + proxy

So I am attempting to have a standalone javascript client running cesium. I currently have this working using node-webkit (https://github.com/rogerwang/node-webkit - thanks much to Robert Wang and the folks at Intel for this great capability). As stated at that URL, “node-webkit is an app runtime based on Chronium and node.js.”

My question is this: This capability works fine when I’m directly connected to the Internet, however when I get onto my corporate VPN and am behind a corporate firewall, I am unable to access any of the imagery providers. Below is my sample code where I attempt to specify the proxy for an ArcGIS Server map server. Note that the proxies[0] just points to my corporate proxy server, along the following lines: hostname.domain.com:80

var arcGisUrl = ‘http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer’;

var cesiumWidget = new Cesium.CesiumWidget(‘cesiumContainer’, {

imageryProvider : new Cesium.ArcGisMapServerImageryProvider({

url : arcGisUrl,

proxy : new Cesium.DefaultProxy(proxies[0])

})

});

When I run this, the globe appears blank.

I would note that while node-webkit does offer node.js support, I am not actually running a local web server here.

I’d appreciate any insight that you can offer.

Thanks.

Todd

Hi Todd,

The “proxy” parameter isn’t meant to be used for a corporate proxy server. That is configured within your web browser. I’m assuming you’re able to browse the web in general, though, so that probably means your corporate proxy is properly configured in your web browser.

Instead, the proxy parameters specifies a proxy service that can be used to work around CORS restrictions. It is necessary because some imagery providers, including Esri, do not add the proper CORS headers to their responses, and web browsers do not allow WebGL applications like Cesium to use images that are served without proper CORS headers. The proxy service provided with the Cesium web server just requests the specified URL on the server and then returns it, adding the necessary CORS header. If you’re using using a web server other than the one that comes with Cesium, you’ll need to provide your own proxy service. Alternatively, you can use an imagery provider that includes proper CORS headers, such as Bing Maps.

This is all said without ever having tried using node-webkit myself, so I’m not sure why additional variables that might introduce.

Kevin

I was just trying this yesterday and had some interesting issues that I was hoping to bounce off someone. Using node.js I have a simple example working that loads up a czml file. I ran into the CORS issue with the default options. Using the viewer I was able to change the providers using the menu and get some that worked after the initial load. However, no matter what the czml file is never used, although it seems to show it was loaded. So I tried to use the NaturalEarthII provider and that doesn't work either. However, other local png's are loaded without issue.

See the screenshot here: http://i.imgur.com/7NCdknP.png

I read through the path multiple times and somehow missed the extension. For some reason it is requesting .png files instead of the .jpg that exist in the Cesium texture folder.

Still not sure about the czml file though.

You’re running your application off the file system (file:// URL). XMLHttpRequest can’t load resources properly in that situation, and the imagery provider is falling back on png file extensions because it failed to load the tilemapresource.xml file.

You have to use an HTTP server to run your application.

Yeah the http server is run using node.js connect, but I didn't quite have the configuration with node.js and node-webkit setup correctly. I found this doc page on the node-webkit app protocol: https://github.com/rogerwang/node-webkit/wiki/App-protocol which got me almost there.

I have these config files that should be a decent starting point with cesium and node-webkit:
package.json: http://pastebin.com/raw.php?i=a3VbBJpU
Gruntfile.js: http://pastebin.com/raw.php?i=ewFNHZze
add to index.html: http://pastebin.com/raw.php?i=1YGsRNGR

I still is strange that by initializing the cesium viewer with an imagery provider that loads when selected from the menu within Cesium, it doesn't work on the initial load (I assume due to CORS). So choosing the Bing option from the menu doesn't work, but ESRI World Imagery does. However, if I configure ESRI as the default provider when creating the viewer it shows no errors and there is a single blob file in the history. No matter the imageryprovider option it seems to always try to request from bing, and in this case it fails due to CORS.