Configuring Websockets connection to pass through a proxy server

Hey, I'm working on making G.V() fully proxy aware, but I can't seem to get websockets connection to pass through a SOCKS/HTTP proxy configuration. I've got all the proxy configuration java system properties set and working for HTTP connections. Is there any specific configuration to add to let the Gremlin driver to use a configured proxy?
Solution:
GitHub
amazon-neptune-tools/neptune-export/src/main/java/org/apache/tinker...
Tools and utilities to enable loading data and building graph applications with Amazon Neptune. - awslabs/amazon-neptune-tools
Jump to solution
6 Replies
gdotv
gdotvOP11mo ago
at a glance it appears the right way of doing it would be to override the websocketchannelizer with a proxy aware implementation but before I code something crazy i'd like to see if that's the way to go and if there's any sample implementation out there. Also curious (if it's not supported) to know if this should be supported by default in gremlin-driver
gdotv
gdotvOP11mo ago
GitHub
tinkerpop/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin...
Apache TinkerPop - a graph computing framework. Contribute to apache/tinkerpop development by creating an account on GitHub.
gdotv
gdotvOP10mo ago
@spmallette any ideas on this one?
Kennh
Kennh10mo ago
As far as I can tell, gremlin-driver doesn't have support for SOCKS proxies right now. gremlin-driver uses netty as its client library so you would need to add a SOCKS proxy handler to the netty pipeline to support this. Adding something like the Socks4ProxyHandler to https://github.com/apache/tinkerpop/blob/master/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Channelizer.java#L189 might work.
GitHub
tinkerpop/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin...
Apache TinkerPop - a graph computing framework. Contribute to apache/tinkerpop development by creating an account on GitHub.
gdotv
gdotvOP10mo ago
makes total sense, is there a way to implement an overriding channelizer for the gremlin driver? can't see anything documented. Also just had some chat with a user who implemented this and it appears just regular HTTP proxy awareness would do, SOCKS is completely over the top here, at least from what i can tell For reference, i'd like to slide in this type of code in the configure method of the WebSocketChannelizer, before all the pipeline.addLast statements:
// Added for G.V(): Proxy Awareness configuration

String proxyHost = null;
String proxyPort = null;
String proxyUsername = System.getProperty("proxy.user");
String proxyPassword = System.getProperty("proxy.password");
HttpProxyHandler proxyHandler = null;
if(System.getProperty("https.proxyHost") != null && System.getProperty("https.proxyPort") != null){
proxyHost = System.getProperty("https.proxyHost");
proxyPort = System.getProperty("https.proxyPort");
}

if(System.getProperty("http.proxyHost") != null && System.getProperty("http.proxyPort") != null){
proxyHost = System.getProperty("http.proxyHost");
proxyPort = System.getProperty("http.proxyPort");
}

if(proxyHost != null && proxyPort != null){
try{
int proxyPortInt = Integer.parseInt(proxyPort);
InetSocketAddress address = new InetSocketAddress(proxyHost, proxyPortInt);
if(proxyUsername != null && proxyPassword != null){
proxyHandler = new HttpProxyHandler(address, proxyUsername, proxyPassword);
}
else{
proxyHandler = new HttpProxyHandler(address);
}
pipeline.addFirst("proxy-handler", proxyHandler);
}
catch(NumberFormatException e){
// Invalid port number, ignore proxy config
}
catch(IllegalArgumentException | SecurityException e){
// Invalid proxyHost/proxyPortInt configuration, again, ignore proxy config
}
}
// Added for G.V(): Proxy Awareness configuration

String proxyHost = null;
String proxyPort = null;
String proxyUsername = System.getProperty("proxy.user");
String proxyPassword = System.getProperty("proxy.password");
HttpProxyHandler proxyHandler = null;
if(System.getProperty("https.proxyHost") != null && System.getProperty("https.proxyPort") != null){
proxyHost = System.getProperty("https.proxyHost");
proxyPort = System.getProperty("https.proxyPort");
}

if(System.getProperty("http.proxyHost") != null && System.getProperty("http.proxyPort") != null){
proxyHost = System.getProperty("http.proxyHost");
proxyPort = System.getProperty("http.proxyPort");
}

if(proxyHost != null && proxyPort != null){
try{
int proxyPortInt = Integer.parseInt(proxyPort);
InetSocketAddress address = new InetSocketAddress(proxyHost, proxyPortInt);
if(proxyUsername != null && proxyPassword != null){
proxyHandler = new HttpProxyHandler(address, proxyUsername, proxyPassword);
}
else{
proxyHandler = new HttpProxyHandler(address);
}
pipeline.addFirst("proxy-handler", proxyHandler);
}
catch(NumberFormatException e){
// Invalid port number, ignore proxy config
}
catch(IllegalArgumentException | SecurityException e){
// Invalid proxyHost/proxyPortInt configuration, again, ignore proxy config
}
}
the issue im running into is trying to extend the WebSocketChannelizer class or implement my own version, i may be daft here but it's unclear how I can do this i could extend the server version of the channelizer just fine but obviously that's no good the end goal is to set the channelizer in the ClusterBuilder to the new overriden class (all Java stuff btw)
Solution
gdotv
gdotv10mo ago
GitHub
amazon-neptune-tools/neptune-export/src/main/java/org/apache/tinker...
Tools and utilities to enable loading data and building graph applications with Amazon Neptune. - awslabs/amazon-neptune-tools
Want results from more Discord servers?
Add your server