gRPC server to start on specific IP Address - grpc

how can I start gRPC server on some specific IP address?
In every tutorial I found (used and tested) this:
Server server = ServerBuilder.forPort(50051)
.addService(new GreetServiceImpl().)
.build();
server.start();
But I need to specify not just port but full address:
Something like this (non-existing code):
Server server = ServerBuilder.forAddress(154.45.153.1)forPort(50051)
.addService(new GreetServiceImpl().)
.build();
server.start();
Thanks

So I found solution that works:
Server server;
SocketAddress address = new InetSocketAddress("10.0.150.116", 5085);
server = NettyServerBuilder.forAddress(address).addService(new GreetServiceImpl()).build();
server.start();
I do not know if there is some drawback with this approach.

Related

A client can trace route to a server but can a server get the trace route? How?

A client can trace route to a server but can a server get the trace route? How?
This is for HTTPClient download requests. I would like to see the path/hops taken but from the server instead of doing trace route from the client.
Thanks
Since you control the server, you can view what public IP addresses the clients are connecting from. You could then run your own traceroute/tracepath to that IP address. However, the path from your server to a client may not be the same path the packets take from the client to your server. Also, that gives you the path back to the client's public IP. The IP could actually be another router performing NAT. In that case there would technically be more hops that the traceroute/tracepath wouldn't show.

How can Openresty get the socket port in proxy server between prroxy server and upstream server?

I use OpenResty® to proxy my backend server.
The process is client->proxy server->backend server
The question is the comment of the code:
stream {
upstream teststream{
server xxxxxx:1234;
}
server {
listen 1234;
proxy_pass teststream;
content_by_lua_block {
#how to get the proxy server socket port between proxy server and backend server
}
}}
Client sends a message to proxy server, then proxy server forwards the message to backend server.The proxy server will new a socket to connect the backend server, so how to get the proxy server socket port between proxy server and backend server in content_by_lua_block?
There is https://github.com/openresty/lua-upstream-nginx-module
get_servers
syntax: servers = upstream.get_servers(upstream_name)
Get configurations for all the servers in the specified upstream
group. Please one server may take multiple addresses when its server
name can be resolved to multiple addresses.
The return value is an array-like Lua table. Each table entry is a
hash-like Lua table that takes the following keys:
addr
socket address(es). can be either a Lua string or an array-like Lua
table of Lua strings.
...
BTW, both proxy_pass and content_by_lua_block are content phase directives.
Only one will work. Please take a look at this post https://groups.google.com/forum/#!topic/openresty-en/DRocQpM4mVY

How to connect DataSnap client to DataSnap server via proxy server?

The problem is this:
I decided to make a messenger/chat (VCL application) with callback on DataSnap technology (IDE Delphi XE6), has created a simple DataSnap server (tcp / ip + http) without the database, and thick client.
All works fine if the whole thing run on a local network (tcp / ip) or via the Internet (http).Problems arise when run over HTTP and the client machine has a HTTP proxy server, the client application can not connect to my DataSnap server application. Client application gets error "10061 connection refused"
or "Expected datasnap context in request http://[YourServerIP]:[YourPort]/datasnap/tunnel".
I tried to enter IP and port of the proxy server to params of component TSQLConnection.Driver params DSProxyHost and DSProxyPort, turned off my firewall and antivirus software, checked allows traffic to the proxy ip + port, but the problem has not disappeared.
After few days searches, without results, i decided listening requests from client application and response of my DataSnap Server application in HTTPTrace procedure of DSHTTPService1 component, also with software HTTPDebugerPro, and i noticed interesting thing:
when client app connecting to ds server app without proxy server, in request ds server app receive URI with this text "/datasnap/tunnel" and all works fine ds server response "200, OK".
when client app connecting to ds server app with proxy, in request ds server app receive URI with text "http://[YourServerIP]:[YourPort]/datasnap/tunnel" and raised exception with response error "404, Expected datasnap context in request http://YourServerIP:YourPort/datasnap/tunnel".
Has anyone knows solution about this problem? How to connect DataSnap client to DataSnap server via proxy server? I searched solution for this problem several days, I shoveled the Internet but have not yet found a solution.

WebServer listen on SSL and all addresses

I'm implementing a signalR self-hosted service using asp.net OWIN.
My server initialization looks something like this-
string url = "https://*:443";
WebApplication.Start<MyConfigurations>(url);
and on the client side-
var hubUrl = 'https://1.mydomain.com:443';
connection = $.hubConnection(hubUrl);
On the client side, I'm getting a 404 error while negotiating connection to signalR.
If I change the url on the server side to string url = "https://mydomain.com:443";, it works fine.
how do I configure the WebApplication to listen to all requests arriving to the server on port 443 (or any other port, using SSL), regardless of the URL that the client used?
Are you sure nothing else is registered to listen on 443? 'Cause * is a "weak" wildcard and if something else is listening on that port using a "stronger" URL registration than that it would explain why it does not work.
So, first, try https://+:443 and see if that works or even specify a base path like https://+:443/SignalRTest. That's the strongest possible form of wildcard. If you're still having issues, I'd check to make sure there are no other registrations for 443 with something like:
netsh http show urlacl

How to edit HTTP request with Fiddler

Is it possible to edit HTTP request using fiddler so that my asp.net application hosted elsewhere return true for the following code block
HttpContext.Current.Request.Url.Host == "localhost"
Sure you can. Simply add the following:
if (oSession.hostname == "fakelocal"){
oSession.hostname = "localhost";
oSession["x-overrideHost"] = "123.1.1.1"; // <-- Server IP here!
}
Then, use the url: http://fakelocal/whatever in the client.
Fiddler will change the host header to "LOCALHOST" and direct the request to the server IP of your choice.
Note, of course, that this won't work if there's a proxy upstream, because upstream proxies do their own DNS lookups.

Resources