So I create NetTcpBinding on both sever and client side (in a runtime), but how will connection behave in case of configuration conflicts? E.g. if on server I have
binding.ReliableSession.Enabled = true;
and I forget to put same lines on client side, would the reliable session actually be working?
Edit: to rephrase, in case of any binding and any binding property, if they differ on server and client, which one will be used in work?
NetTcpBinding does not enable a reliable session by default. So although your endpoint supports a reliable session, it will not use a reliable session if it is not used/enabled by the client.
This feature needs to be configured in the configuration files for the client and service if a reliable session is required.
Related
I have a project that uses Entity Framework Model First. The data source is in the internet, and I need it work using a network/web proxy for it. I had google it but I can't find any useful result, because all results are about EF's Entities Proxies.
Some helpful code:
The connection string:
<add name="ConnectionName" connectionString="metadata=res://*/Latin.csdl|res://*/Latin.ssdl|res://*/Latin.msl;provider=System.Data.SqlClient;provider connection string="data source=mssqlserver.server.com;initial catalog=DatabaseName;user id=admin;password=adminPass;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
The usage:
static void Main(string[] args)
{
//set the proxy
var proxy = new WebProxy("109.32.24.24", 808);
proxy.Credentials = new NetworkCredential("", "");
WebRequest.DefaultWebProxy = proxy;
var db = new ContextName();
if (db.QNames.First().Name == "Testing")
{
Console.WriteLine("Success Connection!");
Console.ReadKey();
}
}
This raises a network connection error.
EDIT
The proxy that the network have is running over http protocol. I know that http is the protocol you normally use to browse the web with, you do not usually connect to databases with it but it is the only available and this question is about it. You can use web proxies for several .net connections, even Web Services, and my question is about using it with EF, I could't make this working. One last solution could be to use a program like Proxifier and redirect all computer's connections to the specified web proxy, but the idea is making it a bit more configurable.
this application may be running in a internetless network, that the only way for getting internet is using an HTTP proxy
Then you cannot do this, or at least not easily.
When a network is configured such that only HTTP traffic may leave the network, then you are restricted to ... only making HTTP calls. SQL Server's wire protocol is a custom, proprietary binary protocol, that does not resemble HTTP in any way. Hence you cannot connect to a remote instance of SQL Server through an HTTP proxy, if HTTP is your only way out. That's why I asked what kind of proxy you're talking about, because for example a SOCKS proxy does allow arbitrary TCP connections to run through it, and Windows supports it natively.
You can however set up an HTTP tunnel through the proxy. See Tunnel any kind of TCP traffic through HTTP/s. This assumes you control both sides of the connection, and can run or install arbitrary software (namely the tunneling software) next to your application software.
This also may or may not work depending on the configuration of the client's proxy server.
However, this looks like an XY problem. Depending on the actual problem, there are various approaches.
You do not want to expose, nor connect to SQL Server over the internet anyway.
Perhaps you could write a webservice instead, that your application then consumes. The web service talks HTTP, so it can be connected to through the HTTP proxy without any additional configuration or software. The webservice runs on, or nearby the SQL Server and you can expose your business logic through the service - without having to expose your SQL Server.
Another alternative would be a VPN connection, but again, all that depends on the actual problem and which sides of the connection you can control.
We have a windows application and it consumes WCF sevice and we use Network Load balancing.Sometimes clients could not connect to wcf service(server).
we use NetTcpBinding binding. Can anyone give me an idea to solve this issue.
Can you post your bindings here?
I would turn on tracing in your web service config to check that traffic is indeed reaching all your intended endpoints. NetTcpBinding pools TCP connections by default, so it could be that the client connection has associated itself to a specific server which is now not available. This would then mean that connections would start to fail. It is recommended that you tweak the default binding settings for NetTcpBinding when used in a load balanced scenario to reduce the lease timeout so that requests are load balanced better. http://msdn.microsoft.com/en-us/library/ms730128.aspx
My Intranet users are accessing the Internet through a proxy on the network. I need to monitor and filter certain requests to that proxy on a few machines. In essence, I need to proxy the proxy on the local machine.
How do I insert a local application as a relay between the local system and the Intranet proxy?
I would have to change the local proxy settings to an endpoint on the local machine, which in turn should relay HTTP requests to the outside proxy. But, I have no experience with writing proxies. Is this even possible?
Edit: The term I was looking for is tunneling, not proxying through a proxy. It is possible and I managed it with a TCP pipe.
Why not use an existing proxy server? This has all required capabilities and you don't have to worry about stability and performance.
I wrote a custom TCP tunnel that forwards requests to the Intranet proxy and pointed the browser proxy to the local machine.
I've got a WCF service running on a LAN IIS which is accessible from the internet as well.
The client that consumes the service is an application that runs on the LAN and remotely through the internet. There is no forwarding of anything on the DNS server redirecting http://www.corporate.com/Service to http://serverName/Service so I'm figuring I'll need 2 endpoints on the client.
How do you setup multiple endpoints in the client (is it as simple as copying the existing enpoint generated in the app.config but changing the address?) and how do you configure the client to use a particular endpoint?
You may store endpoint addresses either at app.config, or at resource strings. Then using any condition you pass needed endpoint address to service constructor.
var endpoint = ApplicationSettings.IsRemote ? Resources.RemoteEndPoint: Resources.LocalEndPoint;
var service = new MyWCFService(new BasicHttpBinding(), new Endpoint(endpoint));
The app.config (or web.config) for each copy of the application should have the endpoint for the service set based on the one it needs. For LAN installations, use the LAN-visible endpoint; for all others, use the Internet one.
It may save you a trip to the router, but why not just use the internet endpoint everywhere? If your LAN computers have a gateway to the Net, they can see the externally-visible address.
It is as simple as changing the address and using the endpoint generated in the app config. You may have to change security modes depending on what is supported on either server, or whether they are both running HTTPS or not. We have an application where we build the target endpoint based on relative path to the current URL in a Silverlight application. We also dynamically change the security mode based on HTTPS being present and it works great.
I am a newbie in remoting concepts(C# Remoting).Actually i done some projects using
remoting concepts, i need to employ a proxy between the client and server , if client
wants to communicate with the server or vice-versa it should be done through this proxy
only.i saw a namespace Remoting.Proxy ,will it help? anyone giveme some suggestions on
how to do this it will be very useful for me.
I heard that if the request is through proxy it will be more secure.if my server address is(182.575.069.67) and my proxy runs in 192.168.0.8 then all my clients must send their messages to the proxy and the proxy server must forward this to the actual server.This is what i am trying to do
The "Proxy" namespace refers to the idea that there needs to be a local object, working en-proxy for the remoting client.
If you need all traffic to the server to go through a proxy, you should create two executables: the server, and the proxy server.
The server could accept requests only from the proxy service, while the proxy service itself could be promiscuous.
However, I'm not sure why you would need to set up a proxy service, since you should be able to put any of your autorization / authentication code directly into the server service anyways.
Proxies in C# (especially in the System.Remoting namespace) are local, in-process objects that represent an object in a different process.
They're named after the Proxy Object pattern, not after proxy servers.