Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Can't open Port( reverse ssh port forwarding)

User_5LEKRNov 22 2022

Hello, i have a problem with not being able to open a port on my OCI
my setup: i have a server on my local network running PVE, couple lxc containers..
i host couple services now just for local use but i would like to open it for public/also learn self hosting as i am an IT student
the network is behind a NAT/CGNAT i don't know specificly and this isn't that much important as
i will use reverse ssh port forwarding
connections go like this:
container game server (port 25565 udp and tcp too) (ip: 192.168.0.24)
container has my ssh keys, manages port forwarding with the following command: ssh -nNTv -R 0.0.0.0:25565:192.168.0.24:25565 opc@<my OCI server ip> -i /this-is/where-is/my/ssh.key
i removed private stuff from it, if i run this it successfully forwards port back to 192.168.0.24
3.OCI intance: included photos
ssh-forwarding-to-oracle.pngingress-rules-oracle.pngbut when i check if the required ports are open i got this
oracle-localports-opened-closed.pngso while on localhost its oppened the ports on the network controller side not
the software firewall config:
[opc@instance-20220929-2044 ~]$ sudo iptables --list
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
BareMetalInstanceServices all -- anywhere 169.254.0.0/16

this isn't all of it i haven't posted the "Chain BareMetalInstanceServices (1 references)" section, i might leak private information
i haven't worked with iptables before so if the problem is just a command here, i am realy sorry but i couldn't figure out

could someone please help how can i solve this?, so i can access the services i host locally

Comments

_AZ_

i think i should elaborate that I do expect to receive only one row ( from the select). Anything more (or less) should be deemed an error.

Answer

Well, with the code you have above you *will* get an error: TypeError: 'NoneType' object is not iterable. The reason for that is that fetchone() returns None if there are no rows left to fetch. That error isn't too helpful, though. You will need to do something along these lines:

row = cursor.fetchone()

if row is None:

   raise Exception("Hey, only one row was returned!")

tim, val = row

You will want to replace the Exception message with something a bit more meaningful, of course!

Marked as Answer by _AZ_ · Sep 27 2020
_AZ_

thank you @Anthony . Is there a better approach that i should.could use ( vs fetchone or overall ) ?

You're welcome. That approach works and is reasoanble. If you want to check for too many rows as well, you can do fetchall() which will return an array and check the length of the array instead. If you're worried about getting back too many rows with fetchall() you can also use fetchmany(2) which will tell you if there are 0, 1, or 2 rows available.

1 - 4

Post Details

Added on Nov 22 2022
0 comments
884 views