Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DCC-EX / RedHat++ LocoNet LBServer and TCP binary #141

Closed
DrEVILish opened this issue Jun 18, 2024 · 11 comments
Closed

DCC-EX / RedHat++ LocoNet LBServer and TCP binary #141

DrEVILish opened this issue Jun 18, 2024 · 11 comments
Assignees
Labels
bug Something isn't working

Comments

@DrEVILish
Copy link
Contributor

Unable to connect to RedHat++ LocoNet LBServer

This happens on both macOS -server and debian -server

Tried with multiple ports.

Verified it's not a IoTT/RedHat++ issue as JMRI from the same computer (macOS) can connect and run trains.

/opt/traintastic$ ./traintastic-server 
2024-06-18 03:35:30.181682 traintastic I1001: Traintastic v0.3.0-dev
2024-06-18 03:35:30.182555 traintastic I1006: boost 1.74.0
2024-06-18 03:35:30.182568 traintastic I1007: nlohmann::json 3.10.5
2024-06-18 03:35:30.184749 traintastic I1008: libarchive 3.6.2 zlib/1.2.13 liblzma/5.4.1 bz2lib/1.0.8 liblz4/1.9.4 libzstd/1.5.4
2024-06-18 03:35:30.184779 traintastic I1009: zlib 1.2.13
2024-06-18 03:35:30.184787 traintastic I9002: Lua 5.3.6  Copyright (C) 1994-2020 Lua.org, PUC-Rio
2024-06-18 03:35:30.184845 settings N1008: Loaded settings
2024-06-18 03:35:30.185108 traintastic I1005: Building world index
2024-06-18 03:35:30.192403 server N1005: Discovery enabled
2024-06-18 03:35:30.192444 server N1007: Listening at 0.0.0.0:5740
2024-06-18 03:36:01.623666 connection[192.168.20.57:54145] I1003: New connection
2024-06-18 03:36:03.316943 traintastic N1002: Created new world
2024-06-18 03:36:03.316981 world N1010: Edit mode: enabled
2024-06-18 03:36:15.994546 world N1012: Communication: enabled
2024-06-18 03:36:17.568334 world N1013: Communication: disabled
2024-06-18 03:36:40.111099 world N1012: Communication: enabled
2024-06-18 03:36:40.208353 loconet_1 E2007: Socket write failed (Success)
2024-06-18 03:36:42.560187 world N1014: Power: on
2024-06-18 03:36:43.861528 world N1015: Power: off
2024-06-18 03:36:44.396010 world N1014: Power: on
2024-06-18 03:36:44.995172 world N1013: Communication: disabled
2024-06-18 03:36:45.362276 world N1012: Communication: enabled
2024-06-18 03:36:45.428771 loconet_1 E2007: Socket write failed (Success)

Created a brand new world, added Interface, Loconet, try to connect Fails.

@DrEVILish DrEVILish added the bug Something isn't working label Jun 18, 2024
@reinder
Copy link
Member

reinder commented Jun 18, 2024

@DrEVILish thanks for the log, 2024-06-18 03:36:45.428771 loconet_1 E2007: Socket write failed (Success) was very helpful, the "error" was "Success", there was a success check missing.

Can you verify if this resolved it? (latest master)

@reinder reinder self-assigned this Jun 18, 2024
@DrEVILish
Copy link
Contributor Author

DrEVILish commented Jun 19, 2024

This has fixed the issue for initiating the first connection.

macOS Server:
However if I close the connection using the "toggle connection" button, it shows as 2024-06-19 06:55:47.839898 world N1013: Communication: disabled then crashes. Client UI still shows LocoNet as "Online"

I have to force quit the server.

Screenshot 2024-06-19 at 06 56 13

Currently testing with Debian-server: Results to come.

Same outcome with Debian-Server, full crash have to force kill the process ^C won't kill the process either.

@DrEVILish
Copy link
Contributor Author

DrEVILish commented Jun 19, 2024

When using an actual Loconet Server LbServer this isn't an issue.

Only an Issue when using JMRI / PanelPro - built-in LocoNet Server, possibly similar to issue #53.

@reinder
Copy link
Member

reinder commented Jun 19, 2024

Is it possible for you to run the server with a debugger attached? Maybe that can give a clue why it crashes when connected to JMRI's LBserver.

@reinder
Copy link
Member

reinder commented Jun 19, 2024

Before I forget, can you enable communication debug logging for the LocoNet interface, you can find it on the LocoNet tab of the LocoNet interface dialog.

@DrEVILish
Copy link
Contributor Author

Is it possible for you to run the server with a debugger attached? Maybe that can give a clue why it crashes when connected to JMRI's LBserver.

I'm not sure how to do this, within the context of this build environment. I've not used CMake as part of an Application only built and debugged CPP projects directly, without the "extra" steps.

Before I forget, can you enable communication debug logging for the LocoNet interface, you can find it on the LocoNet tab of the LocoNet interface dialog.

I also enabled PCAP to file:
loconet_1_20240620_000937.pcap.txt

‘√≤°������������ˇ���ì���
This was everything in the PCAP file

To clarify it's still crashing when using LocoNet on RedHat++ as well as the JMRI LocoNet Simulator.
Following Actions as you can see via the console->
Screenshot 2024-06-20 at 00 11 58

@gfgit
Copy link
Contributor

gfgit commented Jun 20, 2024 via email

@reinder
Copy link
Member

reinder commented Jun 21, 2024

This pattern is used in all interface + kernel setups, I'll look into it.

@DrEVILish
Copy link
Contributor Author

I've narrowed down the case to crash the server.

It's just happening on the LbServer.

LocoNet -> TCP binary -> I can enable and disable communications without the server crash
LocoNet -> LbServer -> on Disconnect : server crashes.

I think there is an infinite loop being caused by LbServer.

As soon as I open an LbServer connection the thread is pegged at 100%, have to SIGKILL.

Traintastic is getting a reply
m_version = line.substr(7); returns VERSION: IoTT lbServer 1.0.2

After that nothing is sent back out, I think the error has already happened before "disconnecting" and it's stuck in a loop without the ability to properly close out the connection so it hangs.

This should be corrected by fixing #143

I believe both issues are caused by the same underlying issue.

@DrEVILish
Copy link
Contributor Author

LBServerIOHandler::read()
recieves these messages

VERSION IoTT lbServer 1.0.2[\r\n]
RECEIVE BB 01 00 45
SENT OK BB 01 00 45
RECEIVE E7 0E 01 03 00 00 00 04 00 00 00 00 00 10

However
if(startsWith(line, "RECEIVE ")){}
else if(startsWith(line, "SENT OK ")){}
else if(startsWith(line, "VERSION ")){}
all return false, checked by adding

else {
  std::cout << "FAILED TO MATCH\n";
}

Which logs out "FAILED TO MATCH" when starting LocoNet.

@DrEVILish
Copy link
Contributor Author

#147 fixes this

reinder added a commit that referenced this issue Jun 21, 2024
Fixed new line character skipping, see #141
@reinder reinder closed this as completed Jun 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants