Can't connect to port 8080 using TIDHttp - delphi

Using Delphi 11.
I have two http servers running on my machine ; one on 80 port and other on 8080 .
I can sucesfully use TIDHttp to connect on the 'regular' server on 80 port, like so :
idhttp1.get('localhost');
But when i try to do the same with the server on 8080 port :
idhttp1.get('localhost:8080');
It raises the excepction "Unknown Protocol".
I can connect on both server directly on Chrome using the same addresses. What am i missing , please ?
Thanks

After i posted the question, i figured out.
Instead of
idhttp1.get('localhost:8080');
I needed to use
idhttp1.get('http://localhost:8080');

Related

Mountebank imposter ports not accessible when mountebank started using dotnet-testcontainers

I am using dotnet-testcontainers https://github.com/HofmeisterAn/dotnet-testcontainers to spin up a container with mountebank in my xUnit test.
I can successfully create a mountebank client and create an imposter successfully.
The issue is that when the test is run, the app tries to make a call to the imposter on http://localhost:3000 and gets connection refused.
I can successfully open http://localhost:2525 and can see Mountebank default page. So mountebank is running fine. I also confirmed that the imposter was created successfully on port 3000 by looking at docker container log.
I also tried to use Postman to make a call to my imposter at http:localhost:3000 and get connection refused.
What could be the issue? Is this an issue that port 3000 in the docker container is not exposed or something? Below is my code:
MountebankClient mbClient = new MountebankClient();
var testcontainersBuilder = new TestcontainersBuilder<TestcontainersContainer>()
.WithImage("bbyars/mountebank")
.WithName("mountebank")
.WithPortBinding(2525, false)
.WithHostname("localhost");
var testContainers = testcontainersBuilder.Build();
await testContainers.StartAsync();
var testImposter = mbClient.CreateHttpImposter(3000);
testImposter.AddStub().ReturnsBody(HttpStatusCode.OK, File.ReadAllText(#".\Stubs\testImposter.json"));
mbClient.Submit(testImposter);
Might be useful for someone else who would face this issue. Figured out what the issue was. I was not mapping the host port and the imposter port in the container. Read about published ports https://docs.docker.com/config/containers/container-networking/ and used WithExposedPort(3000) and then did port binding of that port with host port using WithPortBinding(3000,3000) where the first port in this method is host port and second port is container port.
var testcontainersBuilder = new TestcontainersBuilder<TestcontainersContainer>()
.WithImage("bbyars/mountebank")
.WithName("mountebank")
.WithPortBinding(2525, 2525)
.WithExposedPort(3000)
.WithExposedPort(3100)
.WithPortBinding(3000, 3000)
.WithPortBinding(3100, 3100)
.WithWaitStrategy(Wait.ForUnixContainer().UntilPortIsAvailable(2525))
.WithHostname("localhost");

Portforwarding not working

I recently tried to portforward port 80 on my local IP, but as the tutorial said, it should be open on my external IP, which it's not. But it is open on my local ip thought.
I have portforwarded port 80, range 80 UDP and TCP on my local IP: 192.168.1.170
This is the tutorial i followed: https://www.youtube.com/watch?v=RZTYqTGqtjI
I portforwarded my IP in the router settings.
https://image.ibb.co/hGW4fm/Sk_rmbild_345.png
https://image.ibb.co/exWFmR/Sk_rmbild_344.png
IF THE suggested METHOD DOESN'T WORK FOR YOU , DO THIS :-
GOTO -> SECURITY TAB -> REMOTE MANAGEMENT
Enable the Remote Management (or enter 255.255.255.255 in the field) .
This will enable the you to access your LAN from WAN.
For the record :-
Internal Port is the PORT on which the device in your LAN is serving .
External Port is the port which the user enters in the browser . exp :- 127.184.184.19:8080 .
Here 8080 is the external port . And if a device in your LAN runs a http web server at port 80 , then the internal port would be 22.
If the Above methods don't work , then your ISP might be using Carrier NAT which means you would have a different PUBLIC and WAP ip address .
In this case , you should use the WAN ip address shown in your router configuration page to access your LAN from internet. s
Kindly Try to open same URL from different Internet Connection other than LAN

Spray on AWS Bind to localhost/127.0.0.1:80 failed

I have set up everything for spray on my AWS instance.
I am also able to run the sample spray-template successfully.
But the issue is spray-template uses port 8080 to bind when I change port from 8080 to 80.
I am facing below mentioned error.
Bind to localhost/127.0.0.1:80 failed
Below is line from my Boot.Scala file
IO(Http) ? Http.Bind(service, interface = "localhost", port = 8080
Can anyone help me with this?
Thank You.

connection refused when I try to connect client with server

I made a basic client / server datasnap applications and it work in local network through http but when I tried to connect from the internet I get connection refused, here are the steps I followed:
I set at the server component TDSHTTPService to connect through port no 8081 then in the client I set to use same port in TSQLConnection component, and I used my PC public IP in the HostName but when I try to connect I get connection refused.
Any advise ?
Forgot to say the client is Firemonkey app running on Android.
You should go to router admin console, find something like "port forwarding" and route the port (8081) to your computer IP - you have to say the router that traffic on this port should go to your computer

Check Port 80 for sites

I need to check if port 80 is up for the accessing IP.
I have tried
$checkport = #fsockopen($ip, $port, $errnum, $errstr, 2); //The 2 is the time of ping in secs
This is giving a result. But recently I have found that port 80 is up for access from normal connection is also returning as Port 80 up.
Reason I found was : ISP had enabled port80 for those accessing my site.
Can anyone help me out in this regards.
Thanks in advance.
Adarsh

Resources