Cai-Yao opened a new issue, #35777:
URL: https://github.com/apache/arrow/issues/35777

   ### Describe the usage question you have. Please include as many useful 
details as  possible.
   
   
   In the server
   ```
   public class FlightsqlServer {
       private static final Logger LOG = 
LogManager.getLogger(FlightsqlServer.class);
       private final FlightServer flightServer;
       private volatile boolean running;
   
       public FlightsqlServer(int port, ConnectScheduler connectScheduler) {
           BufferAllocator allocator = new RootAllocator(100000);
           Location location = Location.forGrpcInsecure("0.0.0.0", port);
           FlightsqlProducer producer = new FlightsqlProducer();
           flightServer = FlightServer.builder(allocator, location, 
producer).build();
       }
   
       // start Flightsql protocol service
       // return true if success, otherwise false
       public boolean start() {
           try {
               flightServer.start();
               LOG.info("Flightsql network service is started.");
           } catch (IOException e) {
               LOG.warn("Open Flightsql network service failed.", e);
               return false;
           }
           return true;
       }
   
       public void stop() {
           if (running) {
               running = false;
               // close server channel, make accept throw exception
               try {
                   flightServer.close();
               } catch (InterruptedException e) {
                   LOG.warn("close server channel failed.", e);
               }
           }
       }
   }
   ```
   The client code:
   ```
   public class FlightSQLJDBC {
      // JDBC driver name and database URL
      static final String DB_URL = 
"jdbc:arrow-flight-sql://localhost:9040/clickbench?useServerPrepStmts=false&useSSL=false";
   
      //  Database credentials
      static final String USER = "root";
      static final String PASS = "";
   
      public static void main(String[] args) {
      Connection conn = null;
      Statement stmt = null;
      PreparedStatement pre_stmt = null;
      try{
   
         //STEP 3: Open a connection
         System.out.println("Connecting to database...");
         conn = DriverManager.getConnection(DB_URL, USER, PASS);
   
         //STEP 4: Execute a query
         System.out.println("Creating statement...");
         String sql = "select * from hits limit 500000";
         stmt = conn.createStatement();
         ResultSet rs = stmt.executeQuery(sql);
         int rowNum = rs.getRow();
         System.out.println(rowNum);
         //STEP 6: Clean-up environment
         rs.close();
         stmt.close();
         conn.close();
   ......
   ```
   The connect error:
   ```
   java.sql.SQLException: cfjd.org.apache.arrow.flight.FlightRuntimeException: 
UNAVAILABLE: io exception
   Channel Pipeline: [SslHandler#0, ProtocolNegotiators$ClientTlsHandler#0, 
WriteBufferingAndExceptionHandler#0, DefaultChannelPipeline$TailContext#0]
        at 
org.apache.arrow.driver.jdbc.client.ArrowFlightSqlClientHandler$Builder.build(ArrowFlightSqlClientHandler.java:586)
        at 
org.apache.arrow.driver.jdbc.ArrowFlightConnection.createNewClientHandler(ArrowFlightConnection.java:109)
        at 
org.apache.arrow.driver.jdbc.ArrowFlightConnection.createNewConnection(ArrowFlightConnection.java:88)
        at 
org.apache.arrow.driver.jdbc.ArrowFlightJdbcDriver.connect(ArrowFlightJdbcDriver.java:85)
        at 
org.apache.arrow.driver.jdbc.ArrowFlightJdbcDriver.connect(ArrowFlightJdbcDriver.java:49)
        at java.sql.DriverManager.getConnection(DriverManager.java:664)
        at java.sql.DriverManager.getConnection(DriverManager.java:247)
        at FlightSQLJDBC.main(FlightSQLJDBC.java:22)
   Caused by: cfjd.org.apache.arrow.flight.FlightRuntimeException: UNAVAILABLE: 
io exception
   Channel Pipeline: [SslHandler#0, ProtocolNegotiators$ClientTlsHandler#0, 
WriteBufferingAndExceptionHandler#0, DefaultChannelPipeline$TailContext#0]
        at 
cfjd.org.apache.arrow.flight.CallStatus.toRuntimeException(CallStatus.java:131)
        at 
cfjd.org.apache.arrow.flight.grpc.StatusUtils.fromGrpcRuntimeException(StatusUtils.java:164)
        at 
cfjd.org.apache.arrow.flight.grpc.StatusUtils.fromThrowable(StatusUtils.java:185)
        at 
cfjd.org.apache.arrow.flight.auth2.ClientHandshakeWrapper.doClientHandshake(ClientHandshakeWrapper.java:59)
        at 
cfjd.org.apache.arrow.flight.FlightClient.handshake(FlightClient.java:210)
        at 
org.apache.arrow.driver.jdbc.client.utils.ClientAuthenticationUtils.getAuthenticate(ClientAuthenticationUtils.java:105)
        at 
org.apache.arrow.driver.jdbc.client.utils.ClientAuthenticationUtils.getAuthenticate(ClientAuthenticationUtils.java:93)
        at 
org.apache.arrow.driver.jdbc.client.ArrowFlightSqlClientHandler$Builder.build(ArrowFlightSqlClientHandler.java:575)
        ... 7 more
   Caused by: cfjd.io.netty.handler.ssl.NotSslRecordException: not an SSL/TLS 
record: 
00001204000000000000037fffffff000400100000000600002000000004080000000000000f0001
        at 
cfjd.io.netty.handler.ssl.SslHandler.decodeJdkCompatible(SslHandler.java:1215)
        at cfjd.io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1285)
        at 
cfjd.io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:519)
        at 
cfjd.io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:458)
        at 
cfjd.io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:280)
        at 
cfjd.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
        at 
cfjd.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
        at 
cfjd.io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
        at 
cfjd.io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
        at 
cfjd.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
        at 
cfjd.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
        at 
cfjd.io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
        at 
cfjd.io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
        at 
cfjd.io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:788)
        at 
cfjd.io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724)
        at 
cfjd.io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650)
        at cfjd.io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562)
        at 
cfjd.io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
        at 
cfjd.io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
        at 
cfjd.io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.lang.Thread.run(Thread.java:748)
   ```
   How should I solve it? Is there something wrong with the server?
   
   ### Component(s)
   
   FlightRPC, Java


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@arrow.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to