Click here to Skip to main content
15,116,654 members
Home / Discussions / C#
   

C#

 
GeneralRe: JSON to DataGrid View Pin
seipekm24-Oct-15 0:21
Memberseipekm24-Oct-15 0:21 
GeneralRe: JSON to DataGrid View Pin
OriginalGriff24-Oct-15 0:31
mveOriginalGriff24-Oct-15 0:31 
GeneralRe: JSON to DataGrid View Pin
seipekm24-Oct-15 0:38
Memberseipekm24-Oct-15 0:38 
GeneralRe: JSON to DataGrid View Pin
OriginalGriff24-Oct-15 0:42
mveOriginalGriff24-Oct-15 0:42 
GeneralRe: JSON to DataGrid View Pin
seipekm24-Oct-15 0:52
Memberseipekm24-Oct-15 0:52 
GeneralRe: JSON to DataGrid View Pin
OriginalGriff24-Oct-15 1:08
mveOriginalGriff24-Oct-15 1:08 
GeneralRe: JSON to DataGrid View Pin
seipekm24-Oct-15 2:24
Memberseipekm24-Oct-15 2:24 
Questionavro - c# to Java, on Flush or Close - “The underlying connection was closed” C# side upon Java HttpExchange.getResponseBody().flush() Pin
devvvy22-Oct-15 15:28
Memberdevvvy22-Oct-15 15:28 
I am using avro calling Java from c#. Error message "The underlying connection was closed: The connection was closed unexpectedly." C# side upon Java call to flush or close

C# side fires off the request from here:
            httpRequest = HttpWebRequest.Create(targetUrl) as HttpWebRequest;
            httpRequest.Method = "POST";
            httpRequest.Accept = "avro/binary";
            httpRequest.ContentType = "avro/binary";
            httpRequest.KeepAlive = false;

<pre>
        SpecificDatumWriter<SomeRequest> someRequestWriter = new SpecificDatumWriter<SomeRequest>(SomeRequest._SCHEMA);
        ...
        using (var requestStream = httpRequest.GetRequestStream())
        {
            someRequestWriter.Write(someRequest, new Avro.IO.BinaryEncoder(requestStream));

            // C# blows up here!!!
            using (var responseStream = httpRequest.GetResponse().GetResponseStream())
            {
                SpecificDatumReader<SomeResponse> someResponseReader = new SpecificDatumReader<SomeResponse>(null, SomeResponse._SCHEMA);
                someResponse = someResponseReader.Read(null, new Avro.IO.BinaryDecoder(responseStream));
                ...
            }
        }</pre>

And java side handles the request, and respond like this:

HttpExchange.getResponseBody().flush() or HttpExchange.close()
public void handle(HttpExchange t) throws IOException {
        final DecoderFactory decoderFactory = DecoderFactory.get();
        final Decoder decoder = decoderFactory.binaryDecoder(t.getRequestBody(), null);
        SpecificDatumReader<demo.avro.SomeRequest> someRequestReader = new org.apache.avro.specific.SpecificDatumReader<demo.avro.SomeRequest>(GenericRequest.class) ;
        SomeRequest req = someRequestReader.read(null, decoder);
        ...

<pre>
    SomeResponse someResponse = new SomeResponse();
    someResponse.setUserId("john.doe");
    someResponse.setResultItemList(results);

    DatumWriter<SomeResponse> someRequestWriter = new org.apache.avro.specific.SpecificDatumWriter<SomeResponse>(SomeResponse.class);

    final EncoderFactory encoderFactory = EncoderFactory.get();
    final Encoder encoder = encoderFactory.binaryEncoder(t.getResponseBody(), null);

    someRequestWriter.write(genericResponse, encoder);

    **// HERE!!! flush or close will blow up C# side**
    // encoder.flush();
    // t.getResponseBody().flush();
    // t.close();

    return;
}</pre>

I don't know how else to "Flush" my response from Java side back to C#. (If I don't flush or close, C# side will still eventually blow up on timeout) Any suggestion?
dev

QuestionUsing NLog in many classes Pin
Member 1206160022-Oct-15 8:08
MemberMember 1206160022-Oct-15 8:08 
GeneralRe: Using NLog in many classes Pin
Member 1206160022-Oct-15 9:28
MemberMember 1206160022-Oct-15 9:28 
AnswerRe: Using NLog in many classes Pin
John Torjo22-Oct-15 11:11
professionalJohn Torjo22-Oct-15 11:11 
GeneralRe: Using NLog in many classes Pin
Member 1206160022-Oct-15 11:34
MemberMember 1206160022-Oct-15 11:34 
GeneralRe: Using NLog in many classes Pin
John Torjo22-Oct-15 11:36
professionalJohn Torjo22-Oct-15 11:36 
GeneralRe: Using NLog in many classes Pin
Member 1206160022-Oct-15 12:16
MemberMember 1206160022-Oct-15 12:16 
GeneralRe: Using NLog in many classes Pin
John Torjo22-Oct-15 23:53
professionalJohn Torjo22-Oct-15 23:53 
GeneralRe: Using NLog in many classes Pin
Richard Deeming23-Oct-15 2:40
mveRichard Deeming23-Oct-15 2:40 
GeneralRe: Using NLog in many classes Pin
Member 1206160023-Oct-15 3:15
MemberMember 1206160023-Oct-15 3:15 
GeneralRe: Using NLog in many classes Pin
Member 1206160023-Oct-15 3:29
MemberMember 1206160023-Oct-15 3:29 
QuestionHow to change Font in Word by C# Pin
naylynn22-Oct-15 4:54
Membernaylynn22-Oct-15 4:54 
AnswerRe: How to change Font in Word by C# Pin
Eddy Vluggen22-Oct-15 9:37
professionalEddy Vluggen22-Oct-15 9:37 
GeneralRe: How to change Font in Word by C# Pin
naylynn25-Oct-15 12:10
Membernaylynn25-Oct-15 12:10 
QuestionCheck Remote Computer Windows Services Pin
Jassim Rahma22-Oct-15 0:07
MemberJassim Rahma22-Oct-15 0:07 
AnswerRe: Check Remote Computer Windows Services Pin
Richard Deeming22-Oct-15 3:48
mveRichard Deeming22-Oct-15 3:48 
QuestionKeyDown for Form and all its Controls Pin
Jassim Rahma21-Oct-15 13:28
MemberJassim Rahma21-Oct-15 13:28 
AnswerRe: KeyDown for Form and all its Controls Pin
BillWoodruff21-Oct-15 16:02
mveBillWoodruff21-Oct-15 16:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.