jgaskins / grpc

Pure-Crystal implementation of gRPC
MIT License
76 stars 12 forks source link

windows IO::EOFError #18

Open dsisnero opened 2 months ago

dsisnero commented 2 months ago

I was able to compile a simple grpc example. when I run the client, I get the following error

C:\windows_home\src\dsisnero\crystal_examples\grpc_test>bin\grpc_client.exe
hostname_arg # => "localhost:5001"
hostname # => "localhost"
port # => 5001
Unhandled exception: End of file reached (IO::EOFError)
  from C:\windows_home\.local\share\scoop\apps\crystal\current\src\io.cr:525 in 'read_fully'
  from lib\grpc\src\http2.cr:247 in 'read'
  from C:\windows_home\.local\share\scoop\apps\crystal\current\src\io.cr:286 in 'read_byte'
  from lib\protobuf\src\protobuf\buffer.cr:21 in 'read_uint64'
  from lib\protobuf\src\protobuf\buffer.cr:131 in 'read_info'
  from src\protobufs\hello_world.pb.cr:16 in 'initialize'
  from src\protobufs\hello_world.pb.cr:16 in 'new'
  from src\protobufs\hello_world.pb.cr:16 in 'from_protobuf'
  from src\protobufs\hello_world_services.pb.cr:34 in 'say_hello'
  from src\client.cr:13 in 'main'
  from src\client.cr:19 in '__crystal_main'
  from C:\windows_home\.local\share\scoop\apps\crystal\current\src\crystal\main.cr:129 in 'main_user_code'
  from C:\windows_home\.local\share\scoop\apps\crystal\current\src\crystal\main.cr:115 in 'main'
  from C:\windows_home\.local\share\scoop\apps\crystal\current\src\crystal\main.cr:141 in 'main'
  from C:\windows_home\.local\share\scoop\apps\crystal\current\src\crystal\system\win32\wmain.cr:37 in 'wmain'
  from D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288 in '__scrt_common_main_seh'
  from C:\WINDOWS\System32\KERNEL32.DLL +75133 in 'BaseThreadInitThunk'
  from C:\WINDOWS\SYSTEM32\ntdll.dll +372520 in 'RtlUserThreadStart'

The client file is as follows:

require "./protobufs/hello_world_services.pb"
require "./protobufs/hello_world.pb"

def main
  user = (ARGV.size > 0) ? ARGV[0] : "world"
  hostname_arg = (ARGV.size > 1) ? ARGV[1] : "localhost:5001"
  pp! hostname_arg
  hostname, port = hostname_arg.split(":")
  port = port ? port.to_i32 : 5001
  pp! hostname
  pp! port
  stub = Greeter::Stub.new("localhost", 50000)
  message = stub.say_hello(HelloRequest.new(name: user)).message
  p "Greeting: #{message}"
  message = stub.say_hello_again(HelloRequest.new(name: user)).message
  p "Greeting: #{message}"
end

main
jgaskins commented 1 month ago

Can you describe what is supposed to be happening here? I ask because you're parsing/defaulting to port 5001 from ARGV, but then hardcoding port 50000 on line 13, so I can't tell if the bug is this shard or your app code. Your stack trace points to line 13, so the problem is in either the connection or the handshake, before a request is sent.

dsisnero commented 1 month ago

just a basic test I actually hard code to "localhost", 50000 for both client and server . Code is here grpc_test