#Hello I need some help writing a text

1 messages ยท Page 1 of 1 (latest)

oblique notch
#

This plugin is written in Python, so you don't need to be familiar with VIM at all to help.

oblique notch
#

TTS has a game open, and I have confirmed that it's listening on port 39998. Here's the payload I'm sending:
Sending: b'{"messageID": 3, "guid": "-1", "script": "print(\"Hello, World\")"}\n'

#

It looks like the server's port goes into the FIN_WAIT_2 state after I attempt to send data. Maybe that's relevant...

viral hill
#

Does it have to be a python plugin? I previously used a node module for it which successfully communicated with TTS.

oblique notch
#

It doesn't have to be python, though I'm very curious what I need to fix.

viral hill
#

Do you have the ports right? TTS listens on 39999 for messages.

oblique notch
#

I have the ports right.

oblique notch
# wraith ridge how do you send this though?

I send via:

def client(ip, port, json_dict):
    with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
        sock.settimeout(11)
        Connect to server
        try:
            sock.connect((ip, port))
        except ConnectionRefusedError:
            print('Connection Refused: Is TTS running? Should it be restarted?')
            return

        # Send data
        payload = (dumps(json_dict) + '\n').encode('utf-8')
        print(f"Sending:     {payload}")
        sock.sendall(payload)

        # Shutdown without receiving data. TTS sends on a different socket.
        sock.close()
        sock.shutdown(1)
wraith ridge
cunning osprey
#

I assume that Connect to server is actually commented.

oblique notch
oblique notch
# cunning osprey I assume that `Connect to server` is actually commented.

I'm not sure what you mean. If you're talking about sock.connect(), here's the documentation: https://docs.python.org/3/library/socket.html#socket.socket.connect

cunning osprey
#

I just looked at the snippet you posted, it looks to me like there is a missing #.

oblique notch
#

Yeah, copypasta error ๐Ÿคฆโ€โ™‚๏ธ

#

So, I can get it all working with netcat. So maybe I should use nc to debug this a little more. I'll let you know how it goes.

#

So... When I open netcat to listed for TTS's response: nc -l 127.0.0.1 39998
I get no response after VIM sends using that send function. I suspect I'm sending the JSON in a format that TTS isn't expecting.

#

When I send trash to TTS via nc on 39999, it doesn't even bother replying over 39998. That makes me think I'm sending "trash" from my send function. Maybe I'm converting my JSON dict to a byte object in a silly way.

oblique notch
#

Ok, working with netcat shows that neither my client nor my server work with TTS.