datarhei / gosrt

Implementation of the SRT protocol in pure Go
https://datarhei.com
MIT License
114 stars 17 forks source link

Does not work on Windows #12

Closed tobbee closed 1 year ago

tobbee commented 1 year ago

@ioppermann ‘It is really great to have a pure-Go implementation of SRT. Thanks a lot for providing it!

It works nicely on Linux and Mac, but not on Windows.

The main reason is the calls to SetSockOptInt. I have a branch where I fix that. Currently by disabling setting socket options in Dial on Windows, since there is no way to use File and then File().fd() on Windows.

I have a worse problem in that the srt.Conn always hangs on Read() after some TS packets have been read, typically within a few seconds. Do you have any idea what could be the cause and any way of trouble-shooting it?

ioppermann commented 1 year ago

Unfortunately, I don't have a Windows box available to test it on, so it will be difficult for me to provide an alternative to SetSockOptInt. It should have build tags for the platforms then. Is your modification suitable for a pull request?

Is the hanging srt.Conn on Read() also only happening on Windows? Or on Linux/Mac as well?

For debugging you can use the built-in logging. You will find an example of how to use the logging in the contributed client or server.

tobbee commented 1 year ago

I made a draft PR #13 with the basic SetSockOpt made that you can have a look on.

I'm also not much of a Windows person, so I've mainly used a borrowed pretty old machine running Windows10 for the tests this far. Hopefully, I should soon get a better machine to experiment on.

The hanging only occurs on Windows. I'll try to enable logging, and maybe add some more log lines in the code and see if I can pinpoint what happens.

ioppermann commented 1 year ago

I now have the same problem with the hanging Read() on a linux/arm32 machine. This might be the same problem. I'll investigate.

tobbee commented 1 year ago

Interesting. I tried on a new machine, and then it worked on Windows 11, so I don't think it is a general Windows problem, but rather some limit in specific machine/context.

One of the test applications, didn't work though, so I don't think it is time to include this code in the main branch, since it would be nice to be able to run the same GitHub action on all operating systems. If I get time, I'll look a bit more on this and possibly extend the Github actions with tests for Windows.

ioppermann commented 1 year ago

I fixed the bug that I encountered. It is probably the same issue that you had: datarhei/gosrt@4a4d09f

The problem appeared when packets either never arrive or arrive extremely late. This was not operating system specific. You might check out the v0.5.0 tag.

The next steps are to bring your pull request into the main branch and to actually implement the SetDeadline() functions on a connection. This would prevent a Read() or Write() from blocking forever.

ioppermann commented 1 year ago

Your pull request is now merged. I made some changes to it in order to avoid a single function for each socket option. Also for dialing, the TOS and TTL might work on Windows now. Check the net.go and net_windows.go files.

svenerbeck commented 1 year ago

Hello @tobbee

We are closing your ticket https://github.com/datarhei/gosrt/issues/12.

This may be due to the following reasons:

You can reopen this ticket at any time!

Please only open related tickets once! Always answer/ask in the original ticket with the same issue!