yasushi-saito / go-netdicom

Golang implementation of DICOM network protocol
MIT License
4 stars 1 forks source link

Client cannot C-ECHO to server #1

Closed Ruxton closed 6 years ago

Ruxton commented 6 years ago

A simple C-ECHO against a server does not work. Tested against Intelerad PACS & the sample server, both of which will return C-ECHO using dcm4che.

client code:

func cEcho() {
    su, err := netdicom.NewServiceUser(netdicom.ServiceUserParams{
        CalledAETitle:  "Test",
        CallingAETitle: "bogusae",
        SOPClasses:     sopclass.VerificationClasses})
    if err != nil {
        log.Fatal(err)
    }
    defer su.Release()
    su.Connect("localhost:10000")
    echoErr := su.CEcho()
    if(echoErr != nil) {
        log.Printf("ERROR ECHOING %s", echoErr)
    }
}

func main() {
  cEcho()
}

The server errors at https://github.com/yasushi-saito/go-netdicom/blob/master/statemachine.go#L824

I1025 12:28:32.365364   59875 sampleserver.go:308] Listening on :10000
I1025 12:28:38.076849   59875 statemachine.go:211] Issue Transport connection resp - {5 <nil> <nil> 0xc42002e0b8 <nil> <nil>}
I1025 12:28:38.076956   59875 statemachine.go:826] sm(p)-33: Starting network reader, maxPDU 4194304
I1025 12:28:38.079298   59875 statemachine.go:831] sm(p)-33: Failed to read PDU: EOF
I1025 12:28:38.079327   59875 statemachine.go:873] sm(p)-33: Exiting network reader
I1025 12:28:38.079368   59875 statemachine.go:919] sm(p)-33: Current state: sta02(Transport connection open (Awaiting A-ASSOCIATE-RQ PDU)), Event {17 <nil> <nil> <nil> <nil> <nil>}
I1025 12:28:38.079398   59875 statemachine.go:934] sm(p)-33: Running action AA-5(Stop ARTIM timer)
I1025 12:28:38.079374   59875 serviceprovider.go:474] Finished provider

It's like the client never sends the A-ASSOCIATE stuff and just disconnects in waitUntilReady at https://github.com/yasushi-saito/go-netdicom/blob/master/serviceuser.go#L148

Ruxton commented 6 years ago

Just noticed where I was doing defer su.Release() and it's now behaving itself :( sorry about the false positive.