hashicorp / go-plugin

Golang plugin system over RPC.
Mozilla Public License 2.0
5.25k stars 450 forks source link

client Error:Unrecognized remote plugin message... #199

Open klayyu opened 2 years ago

klayyu commented 2 years ago

Hi,there, thank you for the great go-plugin, I am getting this error when using 3rd log package. client Error:Unrecognized remote plugin message...

how can i stop sync log info from plugin to host, or can i use 3rd log package?

yockii commented 1 year ago

I found it will print a debug level log when start plugin with an unrecognized format, if i turn the log to above debug level (info eg.), this will successfully run over.

code here: https://github.com/hashicorp/go-plugin/blob/5a212b5b9ae4c3bed24ad357f98a8d1c9f23e8a4/server.go#L401

gilwo commented 1 year ago

Hi, I hope this will be useful for some,

after digging into the problem myself in my project I reached to the following conclusions:

hence in my project I routed all my logs to the plugin logging mechanics and turned off all messages going to stdout before calling plugin.Serve() (on the plugin side)

tomhjp commented 1 year ago

@gilwo is spot on - any logging from the plugin should be written to stderr, and then go-plugin will ship those logs into the client's logger output. Technically you could print to stdout after the connection has been successfully negotiated in Start() (called from Client()) but I'd recommend sticking to stderr which is where go-plugin expects any logs to be printed.