Berserk-Games / atom-tabletopsimulator-lua

Tabletop Simulator scripting package for Atom.
Other
36 stars 27 forks source link

Uncaught TypeError: this.stopConnection is not a function #3

Open github-bdem opened 8 years ago

github-bdem commented 8 years ago
  1. Open Tabletop Simulator
  2. Open Atom
  3. Load Single Player Game
  4. Edit Global.-1.lua
  5. Issue command 'Tabletopsimulator Lua: SaveAndPlay'

Uncommenting the console.log functions in 'lib/tabletopsimulator-lua.coffee' it looks like tabletop simulator isn't listening on the port specified there (39999).

Error: connect ECONNREFUSED 127.0.0.1:39999(…)

Possibly something to do with the linux build?

Atom Version: 1.7.2 System: Debian GNU/Linux Thrown From: tabletopsimulator-lua package, v1.1.3

Stack Trace

Uncaught TypeError: this.stopConnection is not a function

At /home/bdell/.atom/packages/tabletopsimulator-lua/lib/tabletopsimulator-lua.coffee:235

TypeError: this.stopConnection is not a function
    at Socket.<anonymous> (/home/bdell/.atom/packages/tabletopsimulator-lua/lib/tabletopsimulator-lua.coffee:235:8)
    at emitOne (events.js:77:13)
    at Socket.emit (events.js:169:7)
    at emitErrorNT (net.js:1253:8)
    at doNTCallback2 (node.js:465:9)
    at process._tickCallback (node.js:379:17)

Commands

     -0:07.7.0 editor:select-to-first-character-of-line (atom-text-editor.editor.is-focused)
  3x -0:07.3.0 core:backspace (atom-text-editor.editor.is-focused)
     -0:01.2.0 tabletopsimulator-lua:saveAndPlay (atom-text-editor.editor.is-focused)

Config

{
  "core": {
    "disabledPackages": [
      "linter-pep8",
      "linter-pylint",
      "jshint",
      "emmet",
      "metrics"
    ],
    "themes": [
      "atom-material-ui",
      "monokai"
    ]
  }
}

Installed Packages

# User
Sublime-Style-Column-Selection, v1.5.1
atom-html-preview, v0.1.19
atom-material-ui, v1.2.10
atom-ternjs, v0.13.2
autoclose-html, v0.23.0
autocomplete-paths, v1.0.2
autocomplete-python, v1.7.2
file-icons, v1.6.18
fonts, v1.2.0
highlight-line, v0.11.1
highlight-selected, v0.11.2
jsformat, v0.9.3
linter, v1.11.4
linter-eslint, v7.1.3
linter-lua, v1.0.2
minimap, v4.21.0
minimap-highlight-selected, v4.4.0
monokai, v0.18.0
pigments, v0.26.0
project-manager, v2.7.6
tabletopsimulator-lua, v1.1.3
tabs-to-spaces, v1.0.2

# Dev
No dev packages

Console output

Window load time: 1453ms
Listening to localhost:39998
Checking for tabletopsimulator-lua updates:
Package Updates Available (0)
└── (empty)

New connection from 127.0.0.1
127.0.0.1 sent: {
  "messageID": 1,
  "scriptStates": [
    {
      "name": "Global",
      "guid": "-1",
      "script": "--[[ Lua code. See documentation: http://berserk-games.com/knowledgebase/scripting/ --]]\n\n--[[ The OnLoad function. This is called after everything in the game save finishes loading.\nMost of your script code goes here. --]]\nfunction onload()\n    --[[ print('Onload!') --]]\nend\n\n--[[ The Update function. This is called once per frame. --]]\nfunction update ()\n    --[[ print('Update loop!') --]]\nend"
    }
  ]
}
Error: connect ECONNREFUSED 127.0.0.1:39999(…)
Uncaught TypeError: this.stopConnection is not a function
dopeghoti commented 8 years ago

Have you verified that you actually have a process listening on that TCP port for Atom to connect to? (netstat -plnt | grep 39999)

github-bdem commented 8 years ago

I will have to double check to see if any other process is running on there when I get home, however when grepping for 'Tabletop' none of the active ports for it were 39999.

tranek commented 8 years ago

I might have fixed that one error message in my local repo:

Uncaught TypeError: this.stopConnection is not a function

It won't fix the connection refused problem though. I'll take a look in my Ubuntu VM to see if I can reproduce this.

Edit: I can confirm that I'm getting this connection refused too on Linux. That's frustrating. Thanks for reporting.

github-bdem commented 8 years ago

'netstat -plnt | grep 39999' returns nothing. Checking 'lsof -i' as root (and normal user) I see

...
steam     6577 bdell   32u  IPv4 637524      0t0  TCP localhost:57343 (LISTEN)
....
Tabletop  6838       bdell    9u  IPv4 761152      0t0  UDP *:1715 
Tabletop  6838       bdell   62u  IPv4 664433      0t0  TCP localhost:48200->localhost:57343 (ESTABLISHED)
atom      8897       bdell  107u  IPv4 768068      0t0  TCP localhost:39998 (LISTEN)

Which implies to me that Tabletop Simulator is not listening for anything (when played in sp mode) on the current linux build (since port 57343 appears to be a steam specific port as the listen server running on there has the same PID as the main steam process). Based on this info I think that this issue is up to the game devs to fix (not sure how else I can help but let me know).

dopeghoti commented 8 years ago

Indeed, if port 39999 is the port that TTS is listening on for Atom connections, it appears not to be doing so in your case.

github-bdem commented 8 years ago

There is another (apparently random) port that TTS uses (1715 in my last post), however that port refuses connection as well.

tranek commented 8 years ago

Right now TTS fires up a thread that has a blocking TCPListener accepting TCPClients. It works fine on Windows but under Linux it's throwing a SocketException: Operation on non-blocking socket would block which terminates the thread. I set the Socket inside of the TCPClient to be blocking so it's not making sense.

I'll probably have to contact Unity to figure this one out.

Sorry for the inconvenience of waiting.

pcastanedav commented 8 years ago

Hello I was able to reproduce the: SocketException: Operation on non-blocking socket would block using Mono and the code posted here (I 'm assuming this forum question is from you guys) : http://forum.unity3d.com/threads/linux-socketexception-operation-on-non-blocking-socket-would-block.399238/

I also couldn't find why AcceptTcpClient() was throwing the error, the best solution I thought of was create a new TcpListener class with a new AcceptTcpClient that checks if current OS is Unix, if is not procede as usual, if it is use BeginAcceptTcpClient and then ManualResetEvent to make it block:

class TcpListenerAsyncState {
    public TcpListenerAsyncState(TcpListener listener) {
        clientConnected = new System.Threading.ManualResetEvent (false);
        this.listener = listener;
    }
    public System.Threading.ManualResetEvent clientConnected;
    public TcpClient currentClient;
    public TcpListener listener;
    public static void AcceptTcpClientCallback(IAsyncResult ar) {
        var state = (TcpListenerAsyncState) ar.AsyncState; 
        state.currentClient = state.listener.EndAcceptTcpClient (ar);
        state.clientConnected.Set ();
    }
}

class TcpListener : System.Net.Sockets.TcpListener {

    public TcpListener (IPAddress localaddr, int port): base(localaddr, port){}
    public TcpListener (IPEndPoint localEP) : base (localEP){}

    public new TcpClient AcceptTcpClient() {
        if (Environment.OSVersion.Platform != PlatformID.Unix) {
            return base.AcceptTcpClient ();
        }
        var state = new TcpListenerAsyncState (this);
        var callback = new AsyncCallback (TcpListenerAsyncState.AcceptTcpClientCallback);
        BeginAcceptTcpClient (callback, state);
        state.clientConnected.WaitOne ();
        return state.currentClient;
    }
}

It works fine under regular Mono, I don't know if Unity adds restrictions over what you can use in System.

Hope this helps.

Xasin commented 7 years ago

Writing from 2017 I want to mention that this issue still persists, which really is a shame as I would absolutely love to script some games.

@tranek Have there been any changes to this lately?

Kippiii commented 7 years ago

Could no one figure this out?

indvd00m commented 6 years ago

Same problem.

jonesmz commented 6 years ago

Still a problem.

Preventing me from working on mods.

Please resolve this bug...

sheybey commented 5 years ago

For those interested, this issue was apparently silently fixed at some point in the intervening time. I can't find a patch note for it, but TTS is listening on the port it supposed to on my Debian system and responds to messages.

onelivesleft commented 5 years ago

Can you confirm it's working correctly, consistently? I tried to fix it last patch, but it hasn't been thoroughly tested.

On Fri, 11 Oct 2019, 20:37 Sam Heybey, notifications@github.com wrote:

For those interested, this issue was apparently silently fixed at some point in the intervening time. I can't find a patch note for it, but TTS is listening on the port it supposed to on my Debian system and responds to messages.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Berserk-Games/atom-tabletopsimulator-lua/issues/3?email_source=notifications&email_token=AEINQFOXNUXEKYMSCFKAPHLQODIXRA5CNFSM4CBNF2T2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBBAGCI#issuecomment-541197065, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEINQFJXODQKKVYI4ALWUTLQODIXRANCNFSM4CBNF2TQ .

sheybey commented 5 years ago

TTS is consistently listening on its socket and both the official Atom extension and my Sublime plugin work as expected. I am running the latest Steam release build on Debian bullseye.

I haven't tested every bit of functionality, but I have tested "save and play" in Atom which connects to TTS to send messages. I will do more thorough testing as I work on my Sublime plugin.

onelivesleft commented 5 years ago

That's good to hear, thank you!

On Fri, 11 Oct 2019, 23:33 Sam Heybey, notifications@github.com wrote:

TTS is consistently listening on its socket and both the official Atom extension and my Sublime plugin work as expected. I am running the latest Steam release build on Debian bullseye.

I haven't tested every bit of functionality, but I have tested "save and play" in Atom which connects to TTS to send messages. I will do more thorough testing as I work on my Sublime plugin.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Berserk-Games/atom-tabletopsimulator-lua/issues/3?email_source=notifications&email_token=AEINQFLXN6MASWNP3CVSMUDQOD5MDA5CNFSM4CBNF2T2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBBMCXI#issuecomment-541245789, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEINQFIG5Q32DH6JBQZZCOTQOD5MDANCNFSM4CBNF2TQ .

indvd00m commented 5 years ago

I'm confirm, "Save and Play" now works as expected.

rcjsuen commented 4 years ago

Is Tabletop Simulator always listening for connections on 39999? If I boot it up and run netstat, should I be able to see 39999 listed? I'm on Windows 10.

andymeneely commented 4 years ago

Ugh this is happening to me too. Similar behavior as this forum post where 39999 is up initially, then goes down randomly. I can even watch it in Resource Monitor. Atom plugin won't work as a result.