client报错是怎么回事?
server没问题,一旦运行client就报错
server没问题,一旦运行client就报错
2020-03-19
老师的代码没有问题,有相同错误的自己纠正。查看
private Response invokeRemote(Request request) { Response resp = null; TransportClient client = null; try { client = selector.select(); byte[] outBytes = encoder.encode(request); InputStream receive = client.write(new ByteArrayInputStream(outBytes)); byte[] inBytes = IOUtils.readFully(receive, receive.available()); resp = decoder.decode(inBytes, Response.class); } catch (IOException e) { log.warn(e.getMessage(), e); resp = new Response(); resp.setCode(1); resp.setMessage("RpcClient got error:" + e.getClass() + ":" + e.getMessage()); } finally { if(client != null){ selector.release(client); } } return resp; }
这部分代码是否有误。祝大家秋招顺利~
举报