I need a small direction for below task.
We are consuming APIs for getting some values. The company who written APIs, allows only our server IP for making request. (Basically, I cannot make API calls with my local machine.) I did the develop on visual studio and now need to test that the code is working fine or not. If I deploy the project on the server seems to be ok. But if there is an error in the code, then I need to do the changes and deploy it again and again. That is bit horrible. Also I won't be able to debug.
What my question is, how to run Visual studio in my local machine and particular API call goes with server? What is the easiest way to do this? Any expert can show me at least a direction, since I never done a task like before.
Additional Info.
- The Server runs on cent os and have a static IP. (I have the relevant credentials for accessing to the service with SSH)
- My local machine is Widows based and has a dynamic IP
- Develop with Visual studio 2019 with C#
CodePudding user response:
I can suggest several directions
- proxy. Just configure http or socks proxy on your server then use such a proxy on your machine. All requests will go through your server and the API will see the server's IP. If the API is a pure-http, this should be enough.
- tunnel/VPN. Configure VPN server on your server, configure your dev machine as the client and route traffic inside VPN tunnel. In this case all traffic, not only http, will go through your server and even if API using some non-http things, it should still work
- remote debugging. Visual studio supports remote debugging. So, you can configure it on your server, then you will be able to run the code on server and debug it from dev machine in real time. I believe that for web-apps there is also a remote deploy, when the app is deployed to the specific server automatically after the every build. So, when proper configured, this will allow you to work on remote server nearly as on local one.
CodePudding user response:
To remote-debug a .NET application on a linux/unix server, do the following:
Start your process (i.e. dotnet myApp.dll) on the remote server.
Then, in Visual Studio, use Debug->Attach to process. Select SSH as transport, and enter "username@IP" in the address box (i.e. "[email protected]"). Now a dialog opens where you can specify some connection details. When everything works, you will be presented with the process list on your server. (Note: This works only if your process does not run as root, otherwise you have to use "root@IP" and previously set a SSH password for root).
As @Serg notes, there might be an automatic deploy mechanism available, but otherwise you can use a tool such as WinSCP to automatically synchronize your build output with the server.
