Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
  • 0
catmandoe1

Localhost ports not supported by internet card?

Question

I'm simply trying to send a string using the internet card's .request() function to a web server (Asp.NET core 6) hosted locally on my machine.

local computer = require("computer")
local component = require("component")
local serialization = require("serialization")
local internet = require("internet")
local event = require("event")
local reactor = component.nc_fission_reactor

...

function sendEnergy()
	data = reactor.getEnergyStored()
	local header = {}
	header["content-type"] = "application/json"
	internet.request("https://localhost:7173/api/energy/sendEnergy", tostring(data), header)
	print("sent energy")
end

...

while true do
  	...
  	sendEnergy()
  	os.sleep(1)
end

So far nothing has come through but hosting the the web server on azure and using the URL there it works fine.

I have also cleared the blacklisted addresses in the "settings.conf" file and nothing is also in the whitelist.

I've changed the header to nil and other things but it didn't help. It seems that it never reaches the web server itself.

Using the REST Client extension in VS Code to test the URL with the same parameters works and i get a result in the server.

Also changing the the address to https://127.0.0.1:7173/api/energy/sendEnergy doesn't make one difference or any other variations of that.

Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0

I once ran into this exact problem, OC by default disables localhost specifically with this default config

blacklist=[
      "127.0.0.0/8",
      "10.0.0.0/8",
      "192.168.0.0/16",
      "172.16.0.0/12"
]

the config supports domain names op addresses in string format and even CIDR notation for easy address ranges.

the reason for this is apparently to prevent user from hosting their game locally and accidentally letting other people access their computers through OC.

If you arent in multiplayer its probably safe to remove this from the config and othherwise you'll have to get some other machine to host your web server on for example a raspberry pi works just fine for this sort of application.

Link to post
Share on other sites
  • 0
On 2/10/2023 at 4:05 PM, coolian said:

I once ran into this exact problem, OC by default disables localhost specifically with this default config


blacklist=[
      "127.0.0.0/8",
      "10.0.0.0/8",
      "192.168.0.0/16",
      "172.16.0.0/12"
]

the config supports domain names op addresses in string format and even CIDR notation for easy address ranges.

the reason for this is apparently to prevent user from hosting their game locally and accidentally letting other people access their computers through OC.

If you arent in multiplayer its probably safe to remove this from the config and othherwise you'll have to get some other machine to host your web server on for example a raspberry pi works just fine for this sort of application.

From the looks of it, after removing all of the addresses and fiddling around with the whitelist a bit in the config i still can't get a packet through.

I'd probably have to go through the mod source and see how it handles http and so on if i want to figure out whats wrong.

Also never thought of using a raspberry pi for running the server and im sure to have one kicking around somewhere so thanks for that.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.