Connecting to Azure Redis from proxy server - java

I am trying to connect to Azure redis cache from inside of corporate network. Could anyone give suggestion how to connnect to Azure redis via Proxy? I am using Jedis and spring boot.

According to the official document and the case Does Azure Redis work over http?, Azure Redis use TCP protocol and does not support HTTP protocol.
So you need to use Socket 4/5 proxy instead of HTTP proxy, then set proxy parameters in the Java app.
Properties prop = System.getProperties();
prop.setProperty("socksProxyHost", "IP ADDRESS");
prop.setProperty("socksProxyPort", "PORT");
Authenticator.setDefault(new MyAuthenticator("userName", "Password"));

Related

Channel binding when connecting in Java to LDAP server - is it possible?

Microsoft has new patch with LDAP connection.
Servers with this patch will not accept connections with no 'channel binding'
My code connects today with 'InitialLdapContext'.
I'm preparing the env and create a new InitialLdapContext.
LDAP/LDAPs working fine.
After this patch,
Will servers reject LDAPs connection?
Will I have to add channel binding handling?
I don't see that InitialLdapContext has channel binding handling.

Using Azure EventHub behind a proxy with authentication

UPDATE
There are some News on that, see here: https://blogs.msdn.microsoft.com/eventhubs/2018/09/21/azure-event-hubs-websockets-and-proxy-support/
====
Azure's EventProcessorHost can be used to register and EventProcessor against an EventHub:
EventProcessorHost host = new EventProcessorHost(
EventProcessorHost.createHostName(null),
connectionStringBuilder.getEventHubName(),
"$Default",
ConnectionStringBuilder.toString(),
this.storageConnectionString,
this.storageContainerName
);
host.registerEventProcessor(MyEventProcessor.class, options).get();
One can add a proxy beforehand:
OperationContext.setDefaultProxy(
new Proxy(Proxy.Type.HTTP, new InetSocketAddress("proxy.url.com", 1234))
);
Question: How to provide an authentication (username/password) to this proxy?
TLDR: EventProcessorHost java library doesn't support proxy yet. This is a feature under construction.
Event Hubs Java Client sdk currently uses AMQPs protocol over TCP (on socket 5671, standard port assigned by IANA) to communicate to Event Hubs Service. We just built, support for Websockets transport; here' the PR. Building a snapshot version on dev branch and adding parameter TransportType=AmqpWebSockets in the ConnectionString should enable the client to talk to the EventHubs service over port 443.
We are building support for proxy using basic auth - by end of September. follow this for updates.

Cannot login into Salesforce with Java using Proxy Server

I wrote Java code to login to Salesforce and ran this code on a firewalled server. For this, I have to specify the proxy url and proxy port before connecting to Salesforce due to the firewall. However, I'm getting an unknownhostexception error for the proxy url. If I try to login via curl with the proxy settings, I am able to connect. How come there is a problem connecting using Java then? Any help is appreciated.
Apparently the issue was caused by JVM configs. We have to configure JVM to use the proxy settings as follows:
System.setProperty("http.proxyHost", crmProxyURL);
System.setProperty("http.proxyPort", crmProxyPort);
Depending on your HTTP library the System settings might not be enough or not needed. In the Salesforce context it is quite possible that one would try using the Jetty HTTP Client. In this case the System properties are ignored and proxy needs to be handled by the Jetty client:
ProxyConfiguration proxyConfig = httpClient.getProxyConfiguration();
HttpProxy proxy = new HttpProxy("proxyHost", proxyPort);
proxyConfig.getProxies().add(proxy);
The Apache HTTP Client, another popular choice, also uses its own little mechanism:
HttpHost proxy = new HttpHost("proxyHost", proxyPort, "https");
RequestConfig config = RequestConfig.custom().setProxy(proxy).build();
HttpGet request = new HttpGet(someURL);
request.setConfig(config);
Interesting here: one can specify to use http or https as the proxy protocol.
In general I found using one of the http client much easier that the JDK low level functions.

Connect to external HTTPS Elasticsearch with Java Client

Since I'd want use the Elasticsearch' Java API, I'm trying to connect to external Elasticsearch's REST Server by using the Java TransportClient, the URL I have to call looks like:
https://ssl-secure-host/their-index/their-type/_search
Obviously I first trusted the certification provided by ssl-secure-host by using the keytool and generated the keystore.jks.
I don't have any other information about the elasticsearch's index, nodes, etc, I have only the URL above.
This is the TransportClient I'm writting in order to establish a connection:
ImmutableSettings.Builder settings = ImmutableSettings.settingsBuilder()
.put("cluster.name", "elasticsearch")
.put("discovery.zen.ping.multicast.enabled", false)
.put("shield.user", "user:password")
.put("shield.ssl.truststore.path", "/Users/me/path/cert/keystore.jks")
.put("shield.ssl.truststore.password", "changeit")
.put("shield.transport.ssl", true);
TransportClient client = new TransportClient(settings)
.addTransportAddress(new InetSocketTransportAddress("ssl-secure-host", ?????));
Could it be possible to establish a connection in any other way or I have to ask to my provider more information about the host, port, etc?
Or, Do I have to resign myself to do this by implementing a simple REST client to query the Elasticsearch's index other people provide me?
Could it be possible that an Apache HTTP Server exists in the front of elasticsearch nodes?
Thank you very much in advance :)
You can use JEST library. It s an HTTP client for ElasticSearch. So you can use it instead the transport client provided by Elasticsearch
check this link:
https://github.com/searchbox-io/Jest

Java HTTP proxy wont connect

How to connect properly using HTTP proxy in java? I can do it with sockProxyHost, but not with http.proxyHost.
If i do with socks, it will wait out for the proxy to connect and then it will create the web request, but if i do it with http it will just create the request and dont connect to the proxy.
System.setProperty("http.proxySet", "true");
System.setProperty("http.proxyHost", "validproxyip");
System.setProperty("http.proxyPort", "validproxyport");
is my code. but it wont connect to the proxy. Please help!
Check out the proxy documentation at Oracle
Either you have a typo, or you are using https and not http, or you access a "No-proxy" host. If you want to be sure, use the ProxySelector.
Try set it in the vm args
java -DproxyHost=proxy.mydomain.com -DproxyPort=3128 your.Main

Categories