nakagami / firebirdsql

Firebird RDBMS sql driver for Go (golang)
MIT License
224 stars 60 forks source link

Firebird Event : Unsupported Family Protocol 17 #110

Closed chiangkl closed 4 weeks ago

chiangkl commented 4 years ago

I am trying to connect to Firebird to monitor an event, the following code produce error "Unsupported Family Protocol 17". (I am using Firebird 3.0.5)

    sbr, err := fbEvent.Subscribe(events, func(event firebirdsql.Event) { //or use SubscribeChan
          fmt.Printf("event: %s, count: %d, id: %d, remote id:%d \n", event.Name, event.Count, event.ID, event.RemoteID)
        })
    if err != nil {
        fmt.Printf("err")
    }

Is this library work well with Firebird 3.0.5.

nakagami commented 4 years ago

It looks like a network configuration issue. Is that Windows box ?

chiangkl commented 4 years ago

Yes, it is a windows 7 box.

The dsn was setup as:- dsn := "sysdba:masterkey@localhost:3050/C:/test/db/A0006.FDB"

nakagami commented 4 years ago

Sorry, I don't why, but I think it might have something to do with the netbios settings

kamilakis commented 2 years ago

Hi, thanks for your work! It works perfect so far! :) I'm also getting this error when using fbEvent.SubscribeChan:

It's from subscriber.go line 168:

if syscall.AF_INET != family {
    return -1, nil, 0, fmt.Errorf("unsupported  family protocol: %x", family)
}

I suspect the family protocol 17 is actually UDP so I'm guessing the server responds in UDP when trying to make a connAuxRequest().

I can't find anything related to UDP in the official Firebird documentation though :(

l-express commented 1 month ago

I also got this problem on several computers under Windows. It doesn't look like it's related to netbios settings

  1. It seems that the syscall.AF_INET != family check is not needed for correct operation.
  2. The second problem was that the ip address parameters for some reason were not in 4,5,6,7 bytes, but in 20,21,22,23 bytes of the buffer.

func (s Subscription) connAuxRequest() (int32, net.IP, int, error) { s.mu.Lock() defer s.mu.Unlock() s.fc.wp.opConnectRequest() auxHandle, _, buf, err := s.fc.wp.opResponse() if err != nil { return -1, nil, 0, err } // family := bytes_to_int16(buf[0:2]) port := binary.BigEndian.Uint16(buf[2:4]) // ip := net.IPv4(buf[4], buf[5], buf[6], buf[7]) ip := net.IPv4(buf[20], buf[21], buf[22], buf[23])

//  if syscall.AF_INET != family {
//      return -1, nil, 0, fmt.Errorf("unsupported  family protocol: %x", family)
//  }

return auxHandle, &ip, int(port), nil

}

After the specified changes in the code, everything works fine. I checked under the Windows operating system with Firebird 3 and Firebird 5. I did not check these changes under Linux.

nakagami commented 1 month ago

I believe this is fixed in this commit https://github.com/nakagami/firebirdsql/commit/29d18e480b0987fb87fbe7ade66560072601269b Could you try it in master HEAD?

l-express commented 4 weeks ago

I have very little experience with Golang. Under Windows, the constant syscall.AF_IRDA is unknown. I don't know what dependency to add to the package. If you comment this constant, everything builds and works fine

nakagami commented 4 weeks ago

I understand. Adding AF_IRDA was a simple mistake on my part.

Is this correct? https://github.com/nakagami/firebirdsql/commit/0ec686eba0f9cefc009c437a88bf0f0778c818be

l-express commented 4 weeks ago

Yes, everything is fine. Thank you so much for your work

nakagami commented 4 weeks ago

Thanks, tagged with v0.9.11 now