how to get client ip for different kinds of clients - glassfish

How Can I get client ip in an ejb interceptor? My application is based on javaee5 and is deployed on glassfish and it has different kind of clients (ejb/MDB/jax-ws webservices) and I have a default interceptor that is responsible to log client ip and etc. Can I use java.rmi.server.RemoteServer? I test it but I'm getting this error :
ServerNotActiveException: not in a remote call
Any Idea?

Related

Connection to the WCF in different environments

I have done some research on connecting to the WCF in different environments. I know that I can use the tag in the web.config to specify the addresses for the endpoint in the different environment.
What I don't understand (and can't find answer to) is that if I have specified the endpoint in all environments in the web.config of my client app, how does the client app know which one to connect?
Thanks!
Per your description, I can’t understand the meaning of “different environments”. In my opinion, the client app used to connect the server is accomplished by using the client proxy class. Alternatively, we create a channel factory to communicate with the server.
These above ways all need a service endpoint address.
For the client proxy class, we specify the name of the endpoint in order to instantiate a proxy class when the auto-generated configuration has multiple service endpoints.
ServiceReference1.ServiceClient client = new ServiceClient("BasicHttpBinding_IService1");
For the way that we connect the service by using Channel factory, we ordinarily specify the service address manually in code.
Feel free to let me know if there is anything I can help with.

Azure Application Gateway with API as a backend pool is not working

I have .net core API inside the web app and that web app is backend pool for azure application gateway. while trying to access the web app got below error.
"502 - Web server received an invalid response while acting as a gateway or proxy server."
On app GW, health prob for that web app in unhealthy but while access the API as a https://abc.azurewebsites.net/api/values then it works.
When we deploy API in Web App Service then apiname.azurewebsites.net does not work give any probes to application gateway and treat unhealthy. API works like xxx.azurewebsites.net/api/values and Application Gateway also know this path. We have to put /api/values in override backend path of http settings. Same have to do in health probes.
Yes, you can first verify if the backend API could access directly without app gateway. Then this error may happen due to the following main reasons:
NSG, UDR or Custom DNS is blocking access to backend pool members.
Back-end VMs or instances of virtual machine scale set are not responding to the default health probe.
Invalid or improper configuration of custom health probes.
Azure Application Gateway's back-end pool is not configured or empty.
None of the VMs or instances in virtual machine scale set are healthy.
Request time-out or connectivity issues with user requests.
Generally, the Backend healthy status and details could point it out and show some clues. You could also verify all of the above reasons one by one according to this DOC.

Self-Host WCF single to many host routing

UPDATE 2: Solved the first problem (note below) - reduced the complexity/scope.
NOTE: If migrating from self-hosting WCF services in Cloud Services to Service Fabric using HttpsBinding then you need to change the HostNameComparisonMode from Exact to StrongWildcard.
I have scenario where I have to open many (100+) WCF Service Hosts to receive callbacks from an external service. They have same Contract but with differing credentials (service certificates are unique to each of our customers).
I would like to know if it is possible to route all requests through a single Host/Router that could check the connecting clients expected service certificate and either a) spoof/ignore (preferably) the service certificate or forward the connection onto the correct host.
I want to avoid having to load hundreds of service hosts with different credentials (which are stored in a database) when the service fabric node first comes up so I don't receive traffic to a service that's not loaded yet. Ideally I could load them when needed or not have to load them at all (spoofing certificate or something).
Looking for someone who is a lot savvier with WCF to shed some light on the possibilities. Thanks.

how to redirect SignalR Request to another Machine

I have many clients connected to a server in SignalR
but I want the server to redirect or route all of the Requests to another server , and to route the response to the clients in the same way used in WCF routing service so how can we do this on SignalR ,please ?
To be more specific
I have a server with a web app published on internet
some of the clients Devices cannot connect to the internet
I need to connect them to the server via an intermediate machine connected to the internet.
The client can connect to this machine and the machine connect to the internet then to the main server.
I used WCF routing services to do it for WCF
but what is the technique for SignalR ?
thanks
You can make each of your SignalR machines individually addressable and then have a single machine manage which clients should connect to which SignalR servers.
Each client could make an Ajax request to the management machine which could then respond with the URL the client should establish a SignalR connection to.
If you need clients on separate machines to be able to communicate with each other using SignalR, you should look into SignalR's scaleout providers: http://www.asp.net/signalr/overview/signalr-20/performance-and-scaling/scaleout-in-signalr
As indicated by the first diagram in the previous link, you can put your SignalR servers behind a dumb load balancer if you decide to use a scaleout backplane.

Auto-resolving a hostname in WCF Metadata Publishing

I am running a self-hosted WCF service. In the service configuration, I am using localhost in my BaseAddresses that I hook my endpoints to. When trying to connect to an endpoint using the WCF test client, I have no problem connecting to the endpoint and getting the metadata using the machine's name. The problem that I run into is that the client that is generated from metadata uses localhost in the endpoint URLs it wants to connect to. I'm assuming that this is because localhost is the endpoint URL published by metadata. As a result, any calls to the methods on the service will fail since localhost on the calling machine isn't running the service.
What I would like to figure out is if it is possible for the service metadata to publish the proper URL to a client depending on the client who is calling it. For example, if I was requesting the service metadata from a machine on the same network as the server the endpoint should be net.tcp://MYSERVER:1234/MyEndpoint. If I was requesting it from a machine outside the network, the URL should be net.tcp://MYSERVER.mydomain.com:1234/MyEndpoint. And obviously if the client was on the same machine, THEN the URL could be net.tcp://localhost:1234/MyEndpoint.
Is this just a flaw in the default IMetadataExchange contract? Is there some reason the metadata needs to publish the information in a non-contextual way? Is there another way I should be configuring my BaseAddresses in order to get the functionality I want?
Thanks,
Mike
What .NET version are you using? If you're using .NET 4.0, add the UseRequestHeadersForMetadataAddressBehavior to your service host:
UseRequestHeadersForMetadataAddressBehavior urh =
new UseRequestHeadersForMetadataAddressBehavior();
serviceHost.Description.Behaviors.Add(urh);
Obviously, this needs to be done prior to opening the service host.
If you're using .NET 3.5, there's a hotfix that adds this behavior: support.microsoft.com/kb/971842.