I am trying to make a background task for a UWP app. The task should be triggered by packets from a web socket connection.
I have tested the web socket and it works as expected.
For the background task to work, according to the Microsoft tutorial on background networking (Network communications in the background), a ControlChannelTrigger must be instantiated and the channel.UsingTransport(socket) method must be called. Then socket.ConnectAsync(...) should be called.
However, when calling socket.ConnectAsync(...) after channel.UsingTransport(socket), the socket.ConnectAsync(...) method throws an exception with the following message.
Exception from HRESULT: 0x80072F75
When called without channel.UsingTransport(socket), the connection is established without problems.
In order to use the socket in a background task, I must establish the connection after calling channel.UsingTransport(socket).
Can anyone shed some light on why this error might be occurring?
Please don't install the IIS server on the same device and use localhost to connect the server. See network isolation topic. When using the server in official WebSocket sample , you can try to copy the server folder and its subfolder to another computer and run the server scripts, then you can connect the server with a IP address such as:
Server uri: ws://xxx.xx.xx.xx/WebSocketSample/echowebsocket.ashx
Besides, please have a try to test the ControlChannelTrigger StreamWebSocket sample.
Also see the Note part in the sample:
When used with the supplied scripts, this Windows Store app sample communicates with another process (IIS server which is a desktop app) on the same machine over loopback for demonstration purposes only. A Windows Store app that communicates over loopback to another process that represents a Windows Store app is not allowed and such apps will not pass Store validation. For more information, see How to configure network isolation capabilities.
Related
PostgreSQL, by default, does not allow remote connections. I know I could change the configuration to allow remote connections, but the software vendor will not support making any changes to the configuration. Since we develop add-on products for this vendor, we cannot simply ignore their wishes.
I would like to access Postgres from a remote computer. But making connections must come from what appears to Postgres as localhost. I'm not at all familiar with what I believe is called a TCP Port Forwarder, or maybe it is called a proxy? or Relay? In any case, I need to make remote connections to Postgres as if the requests were coming from localhost.
I already have a Windows service running on the same server as Postgres, so I would like to add this port forwarder, proxy, rely on this service. We need to do this in c#.
Alternatively, if there is already a tool available for this purpose, that I can run as a service, that would be fine as well.
It is correct that by default Postgres doesn't allow remote connections. But this can easy be changed in the pg_hba.conf file.
For this you just need to add a line with the address of your remote host.
For example:
host postgres all 192.168.12.10/32 md5
Columns:
Type: in your case Host
User: I used postgres in this example, but I recommend you
using a dedicated user as postgres is a superuser.
Database: Which database you want to access via this user and host, I left it to all, but again it is advisable to be more specific
Address: The address of the remote host
The authentication method. (md5 for md5 encrypted password). You can also set trust if you don't want any authentication at all.
For more options I refer to the postgresql documentation: https://www.postgresql.org/docs/9.3/static/auth-pg-hba-conf.html
You say you have a windows service running on the same computer and I take it that you have the code of that service under your control. In theory you can add some code in the service and get the updated binaries installed on that computer. This code can do the proxying between incoming tcp connection from internet and local postgres. From postgres point of view it will look like a localhost connection.
But,
There are some very valid reasons why only local calls are allowed and calls over network are blocked.
Your service may or may not be running with sufficient privileges to listen on a publicly open port.
If any antivirus is running on the machine, it will most certainly flag your app as suspicious and frankly, it is.
Best way to approach this is to ask the vendor nicely to grant access - or to work within the limitations.
It smells of some legal or ethical wrongdoing, but i may be wrong.
Having said that, here are the basic steps:
The service onStart registers a TcpListener on ip 0.0.0.0 and some port known to you.
On a seperate thread in a while(true) loop attempt to GetStream()
Start a TcpClient on ip localhost and postgres port
On a seperate thread in a while(true) loop attempt to GetStream()
In a while(true) loop read from listener's stream and write to client's stream. You may want to use a buffer or an array.
loop until you read a -1
This algo should work in principle.
I hope you are not hacking someone. Please dont.
You need to create a user and allow remote connection to this or an existing user.
you should be able to connecte remotly.
good luck.
i have created an Chat Application in C# using TCPChannel and Remoting Service. My Application have 3 parts one is remoteobject, second is RemoteServer and third one is ClientSide. Everything is Working fine in my pc, mean if i run server application and client application in same server its works very good, because localhost. but when i try to host my server application in my VPS and client application in my pc then i can not connect with my server application. how can i specifies an Static IP to my Server Application so i can access my app from anywhere. please help
You may want to check out your firewall settings. You will need to open a port to allow outside traffic to access the particular port on your machine.
this constructor is using a fixed port: https://msdn.microsoft.com/en-us/library/cdb9dcxt(v=vs.110).aspx
I'm developing a WinRT application. Said application will use a corporate LAN in the end to connect to available services. I suspect things will work smoothly then.
However, I'm having a bit of an issue during development.
Since I'm not on-site where the services are being developed (and where the test services have been deployed) I've been given VPN access using the Cisco Systems VPN client.
Note, that I can access the services using a browser, so I know the connection is working fine.
My issue is that the WindowsRT application doesn't seem to play nice with the VPN connection, and I get the following error when attempting to access the services:
Could not connect to net.tcp://[ServiceIp]/[ServicePath].
The connection attempt lasted for a time span of 00:00:00.0463816.
TCP error code 10013: An attempt was made to access a socket in a way
forbidden by its access permissions [ServiceIp].
AFAIK the above error is thrown when a WinRT application doesn't have the required permission (for example, to access LAN or WAN). However, out of desperation, I've tried ticking ALL the requested capabilities boxes in the package configuration, but I'd still get the same error.
Furthermore we've been given a local version of the services, and in our own LAN the application CAN connect.
Note: I still want to connect to the development machine over the VPN, because that's where all the test data is (our own machine has mock data - it was initially useful, but at this stage we need to do more specific tests).
So it seems like WinRT is throwing a hissy-fit when it's forced to use the Cisco VPN... not that I blame it - I don't like that VPN myself! :P
Still, I'd like to be able to connect to the test services. Any suggestions on how to tackle this issue?
Short Verstion: I have a task that I need to make an application get a computer's camera screenshots, and send to another computer running a Windows Service, in the same local network (but not connected to the internet), along with some other information.
Long Explanation: We have an application that runs in the background while the user takes a survey, and we get the user's information such as ID and we save his answers along with other information (only pictures at the moment).
We convert these pictures to data and send them to a WebService, which then saves in a server.
Now we're implementing an "offline" version of this functionality, and we're supposed to save the user's data to a specific computer in the local area network, running another application that saves these data to later upload them to the server when it's online.
Question What do I need on both PCs for this communication to work?
Is it possible to access the Windows Service in the Host PC if it doesn't have IIS installed? (It'll be a client machine so it probably won't have it).
I've been trying to google to understand what should I search/understand but I couldn't find anything that wasn't about WCF and IIS / Online services.
you need some form of communication between the 2. It could be TCP/IP sockets or WCF or classic webservices... but if it is webservices then you DO need it hosted in IIS just like WCF. But WCF allows you to not only host it in IIS but it can be self hosting in your application or you can also use the Windows Activation Services (WAS) too. TCP/IP sockets can also be a solution here. I would lean towards TCP/IP Sockets as the problem you describe is more suited for this than a full bloated service.
i'm writing a server side application and a windows service which need to be installed on a remote host
the service returns CPU usage to the serverside application - this is NOT the problem
the serverside application deploys the service on the remote host. - also, not the problem
THE PROBLEM:
but how do i setup a socket connection between the two, when i dont want to hardcode the ip address? (for scalability) - do i need to use multicast or is there some devious way of doing this? is there another solution than using sockets? -
i'm new to writing Windows Services.
I need help figuring out how to communicate between the server and the service without hardcoding IP-addr.
thank you in advance.
MY SOLUTION:
I created a windows service, that reads a xml file with the IP and port of the Server application. so when i deploy my client application, i also create a xml file with the network information.
Regards Alex
A lot of communication platforms now use network discovery; there's an article on codeproject that goes into detail about using network discovery.
The problem was, I did not know what machine name the server was running on, in fact I wanted this to be flexible, and selectable by the user.
Seems relevant to http://www.codeproject.com/Articles/16113/Retreiving-a-list-of-network-computer-names-using
Have you thought of using WCF?
http://msdn.microsoft.com/en-us/library/ms731082.aspx
Regarding multicast, you can have a WCF server multicast announce it's availability on a network; see http://msdn.microsoft.com/en-us/library/dd456782.aspx
another solution could be to create the service as a console application with arguments (endpoint ip address) and then just deploy it with the arguments on the remote host