Jetty ALPN / NPN尚未正确配置。当试图使用谷歌云语音API [英] Jetty ALPN/NPN has not been properly configured. When tried to use google cloud speech api

查看:693
本文介绍了Jetty ALPN / NPN尚未正确配置。当试图使用谷歌云语音API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在系统环境变量中设置GOOGLE_APPLICATION_CREDENTIALS后,尝试使用Google云语音API。无法解决任何问题或解决超过2天。



这是我得到的错误

  24-May-2017 17:58:22.287警告[grpc-default-executor-0] io.grpc.internal.ChannelExecutor.drain Runnable在ChannelExecutor 
中抛出异常java.lang.IllegalArgumentException:Jetty ALPN / NPN尚未正确配置。
at io.grpc.netty.GrpcSslContexts.selectApplicationProtocolConfig(GrpcSslContexts.java:174)
at io.grpc.netty.GrpcSslContexts.configure(GrpcSslContexts.java:151)
at io.grpc .netty.GrpcSslContexts.configure(GrpcSslContexts.java:139)
at io.grpc.netty.GrpcSslContexts.forClient(GrpcSslContexts.java:109)
at io.grpc.netty.NettyChannelBuilder.createProtocolNegotiatorByType(NettyChannelBuilder .java:335)
at io.grpc.netty.NettyChannelBuilder.createProtocolNegotiator(NettyChannelBuilder.java:308)
at io.grpc.netty.NettyChannelBuilder $ NettyTransportFactory $ DynamicNettyTransportParams.getProtocolNegotiator(NettyChannelBuilder.java:499 )
at io.grpc.netty.NettyChannelBuilder $ NettyTransportFactory.newClientTransport(NettyChannelBuilder.java:448)
at io.grpc.internal.CallCredentialsApplyingTransportFactory.newClientTransport(CallCredentialsApplyingTransportFactory.java:61)
at io.grpc.internal.InternalSubchannel.startNew Transport(InternalSubchannel.java:209)
at io.grpc.internal.InternalSubchannel.obtainActiveTransport(InternalSubchannel.java:186)
at io.grpc.internal.ManagedChannelImpl $ SubchannelImplImpl.obtainActiveTransport(ManagedChannelImpl.java: 806)
at io.grpc.internal.GrpcUtil.getTransportFromPickResult(GrpcUtil.java:568)
at io.grpc.internal.DelayedClientTransport.reprocess(DelayedClientTransport.java:296)
at io .grpc.internal.ManagedChannelImpl $ LbHelperImpl $ 5.run(ManagedChannelImpl.java:724)
位于io.grpc.internal.ChannelExecutor.drain(ChannelExecutor.java:87)
位于io.grpc.internal。 ManagedChannelImpl $ LbHelperImpl.runSerialized(ManagedChannelImpl.java:715)
at io.grpc.internal.ManagedChannelImpl $ NameResolverListenerImpl.onUpdate(ManagedChannelImpl.java:752)
at io.grpc.internal.DnsNameResolver $ 1.run (DnsNameResolver.java:174)
在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
在java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617)$ b $在java.lang.Thread.run(Thread.java:745)

这是我的POM文件

 <?xml版本= 1.0 >?; 
< project xsi:schemaLocation =http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd
xmlns =http://maven.apache.org/POM/4.0.0xmlns:xsi =http://www.w3.org/2001/XMLSchema-instance>

< modelVersion> 4.0.0< / modelVersion>
< groupId> com.raghu< / groupId>
< artifactId> raghu< / artifactId>
<包装>战争< / packaging>
< version> 1.0.0< / version>
<名称> raghu< / name>

<属性>
< springframework.version> 4.0.6.RELEASE< /springframework.version>
< hibernate.version> 4.3.6.Final< /hibernate.version>
< mysql.version> 5.1.31< /mysql.version>
< joda-time.version> 2.3< /joda-time.version>
< / properties>

<依赖关系>
< dependency>
< groupId> com.google.cloud< / groupId>
< artifactId> google-cloud-speech< / artifactId>
< version> 0.17.1-alpha< / version>
< /依赖关系>

<! - Spring - >>
< dependency>
< groupId> org.springframework< / groupId>
< artifactId> spring-core< / artifactId>
< version> $ {springframework.version}< / version>
< /依赖关系>
< dependency>
< groupId> org.springframework< / groupId>
< artifactId> spring-web< / artifactId>
< version> $ {springframework.version}< / version>
< /依赖关系>
< dependency>
< groupId> org.springframework< / groupId>
< artifactId> spring-webmvc< / artifactId>
< version> 4.0.6.RELEASE< / version>
< /依赖关系>
< dependency>
< groupId> org.springframework< / groupId>
< artifactId> spring-tx< / artifactId>
< version> $ {springframework.version}< / version>
< /依赖关系>
< dependency>
< groupId> org.springframework< / groupId>
< artifactId> spring-orm< / artifactId>
< version> $ {springframework.version}< / version>
< /依赖关系>

<! - Hibernate - >
< dependency>
< groupId> org.hibernate< / groupId>
< artifactId> hibernate-core< / artifactId>
< version> $ {hibernate.version}< / version>
< /依赖关系>

<! - - jsr303验证 - >
< dependency>
< groupId> javax.validation< / groupId>
< artifactId> validation-api< / artifactId>
< version> 1.1.0.Final< / version>
< /依赖关系>
< dependency>
< groupId> org.hibernate< / groupId>
< artifactId> hibernate-validator< / artifactId>
< version> 5.1.2.Final< / version>
< /依赖关系>

<! - MySQL - >
< dependency>
< groupId> mysql< / groupId>
< artifactId> mysql-connector-java< / artifactId>
< version> $ {mysql.version}< / version>
< /依赖关系>

<! - JSON - >
< dependency>
< groupId> com.fasterxml.jackson.core< / groupId>
< artifactId> jackson-databind< / artifactId>
< version> 2.1.2< / version>
< /依赖关系>
<! - Joda-Time - >
< dependency>
< groupId> joda-time< / groupId>
< artifactId> joda-time< / artifactId>
< version> $ {joda-time.version}< / version>
< /依赖关系>

<! - 将JodaTime与数据库类型进行映射 - >
< dependency>
< groupId> org.jadira.usertype< / groupId>
< artifactId> usertype.core< / artifactId>
< version> 3.0.0.CR1< / version>
< /依赖关系>

<! - Servlet + JSP + JSTL - >
< dependency>
< groupId> javax.servlet< / groupId>
< artifactId> javax.servlet-api< / artifactId>
< version> 3.1.0< / version>
< /依赖关系>
< dependency>
< groupId> javax.servlet.jsp< / groupId>
< artifactId> javax.servlet.jsp-api< / artifactId>
< version> 2.3.1< / version>
< /依赖关系>
< dependency>
< groupId> javax.servlet< / groupId>
< artifactId> jstl< / artifactId>
< version> 1.2< / version>
< /依赖关系>

< dependency> <! - 用于核心认证和访问控制类的安全核心 - >
< groupId> org.springframework.security< / groupId>
< artifactId> spring-security-core< / artifactId>
< version> 3.2.3.RELEASE< / version>
< /依赖关系>
< dependency> <! - 用于网络安全基础结构代码的安全网站 - >
< groupId> org.springframework.security< / groupId>
< artifactId> spring-security-web< / artifactId>
< version> 3.2.3.RELEASE< / version>
< /依赖关系>
< dependency> <! - security-config包含安全命名空间解析代码 - >
< groupId> org.springframework.security< / groupId>
< artifactId> spring-security-config< / artifactId>
< version> 3.2.3.RELEASE< / version>
< /依赖关系>
< dependency>
< groupId> com.twilio.sdk< / groupId>
< artifactId> twilio-java-sdk< / artifactId>
< version> 3.4.5< / version>
< /依赖关系>
< dependency>
< groupId> javax.mail< / groupId>
< artifactId>邮件< / artifactId>
< version> 1.4< / version>
< /依赖关系>
< dependency>
< groupId> commons-fileupload< / groupId>
< artifactId> commons-fileupload< / artifactId>
< version> 1.2.2< / version>
< /依赖关系>
< dependency>
< groupId> commons-io< / groupId>
< artifactId> commons-io< / artifactId>
< version> 2.4< / version>
< /依赖关系>
< dependency>
< groupId> com.amazonaws< / groupId>
< artifactId> aws-java-sdk< / artifactId>
< version> 1.9.30< / version>
< /依赖关系>
< dependency>
< groupId> org.apache.httpcomponents< / groupId>
< artifactId> httpclient< / artifactId>
< version> 4.3.4< / version>
< /依赖关系>
< /依赖关系>
< build>
< pluginManagement>
< plugins>
< plugin>
< groupId> org.apache.maven.plugins< / groupId>
< artifactId> maven-war-plugin< / artifactId>
< version> 2.4< / version>
<配置>
< warSourceDirectory> src / main / webapp< / warSourceDirectory>
< warName> raghu< / warName>
< failOnMissingWebXml> false< / failOnMissingWebXml>
< / configuration>
< / plugin>
< plugin>
< groupId> org.apache.maven.plugins< / groupId>
< artifactId> maven-compiler-plugin< / artifactId>
< version> 2.1< / version>
<配置>
< source> 1.8< / source>
< target> 1.8< / target>
< / configuration>
< / plugin>
< / plugins>
< / pluginManagement>
< finalName> raghu< / finalName>
< / build>
< / project>

JAVA实现我试过了

  public String convertToText(MultipartFile file)throws Exception {

SpeechClient speech = SpeechClient.create();

byte [] data = file.getBytes();

ByteString audioBytes = ByteString.copyFrom(data);
System.out.println(1 **********);
//构建同步识别请求
RecognitionConfig config = RecognitionConfig.newBuilder()
.setEncoding(AudioEncoding.LINEAR16)
.setSampleRateHertz(16000)
.setLanguageCode( en-US)
.build();
RecognitionAudio audio = RecognitionAudio.newBuilder()
.setContent(audioBytes)
.build();

//对音频文件执行语音识别
RecognizeResponse response = speech.recognize(config,audio);
List< SpeechRecognitionResult> results = response.getResultsList();

String recText =; (SpeechRecognitionResult result:results){
List< SpeechRecognitionAlternative>


alternatives = result.getAlternativesList(); (SpeechRecognition替代替代:替代品)
{
System.out.printf(转录:%s%n,alternative.getTranscript());
recText + =+ alternative.getTranscript();
}
}
speech.close();

返回recText;
}

我使用Tomcat(我不想使用Jetty)部署我的.war文件。

互联网上有很多问题,他们似乎都没有回答问题。任何帮助将不胜感激!

解决方案

Netty-tcnative 1.x是与Tcat不兼容,正如Tomcat所使用的。不兼容性通过netty-tcantive 2.x解决。使用新的netty-tcnative 必要的更新到grpc-java,这将是包括在下一个版本1.4.0中,计划于6月6日发布。

I tried using Google cloud speech API after setting GOOGLE_APPLICATION_CREDENTIALS in system environment variable. Not able to figure out any issues or work around for more than 2 days.

Here is the error i am getting

24-May-2017 17:58:22.287 WARNING [grpc-default-executor-0] io.grpc.internal.ChannelExecutor.drain Runnable threw exception in ChannelExecutor
 java.lang.IllegalArgumentException: Jetty ALPN/NPN has not been properly configured.
    at io.grpc.netty.GrpcSslContexts.selectApplicationProtocolConfig(GrpcSslContexts.java:174)
    at io.grpc.netty.GrpcSslContexts.configure(GrpcSslContexts.java:151)
    at io.grpc.netty.GrpcSslContexts.configure(GrpcSslContexts.java:139)
    at io.grpc.netty.GrpcSslContexts.forClient(GrpcSslContexts.java:109)
    at io.grpc.netty.NettyChannelBuilder.createProtocolNegotiatorByType(NettyChannelBuilder.java:335)
    at io.grpc.netty.NettyChannelBuilder.createProtocolNegotiator(NettyChannelBuilder.java:308)
    at io.grpc.netty.NettyChannelBuilder$NettyTransportFactory$DynamicNettyTransportParams.getProtocolNegotiator(NettyChannelBuilder.java:499)
    at io.grpc.netty.NettyChannelBuilder$NettyTransportFactory.newClientTransport(NettyChannelBuilder.java:448)
    at io.grpc.internal.CallCredentialsApplyingTransportFactory.newClientTransport(CallCredentialsApplyingTransportFactory.java:61)
    at io.grpc.internal.InternalSubchannel.startNewTransport(InternalSubchannel.java:209)
    at io.grpc.internal.InternalSubchannel.obtainActiveTransport(InternalSubchannel.java:186)
    at io.grpc.internal.ManagedChannelImpl$SubchannelImplImpl.obtainActiveTransport(ManagedChannelImpl.java:806)
    at io.grpc.internal.GrpcUtil.getTransportFromPickResult(GrpcUtil.java:568)
    at io.grpc.internal.DelayedClientTransport.reprocess(DelayedClientTransport.java:296)
    at io.grpc.internal.ManagedChannelImpl$LbHelperImpl$5.run(ManagedChannelImpl.java:724)
    at io.grpc.internal.ChannelExecutor.drain(ChannelExecutor.java:87)
    at io.grpc.internal.ManagedChannelImpl$LbHelperImpl.runSerialized(ManagedChannelImpl.java:715)
    at io.grpc.internal.ManagedChannelImpl$NameResolverListenerImpl.onUpdate(ManagedChannelImpl.java:752)
    at io.grpc.internal.DnsNameResolver$1.run(DnsNameResolver.java:174)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

Here is my POM File

<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
    xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    <modelVersion>4.0.0</modelVersion>
    <groupId>com.raghu</groupId>
    <artifactId>raghu</artifactId>
    <packaging>war</packaging>
    <version>1.0.0</version>
    <name>raghu</name>

    <properties>
        <springframework.version>4.0.6.RELEASE</springframework.version>
        <hibernate.version>4.3.6.Final</hibernate.version>
        <mysql.version>5.1.31</mysql.version>
        <joda-time.version>2.3</joda-time.version>
    </properties>

    <dependencies>
         <dependency>
            <groupId>com.google.cloud</groupId>
            <artifactId>google-cloud-speech</artifactId>
            <version>0.17.1-alpha</version>
        </dependency>

        <!-- Spring -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>4.0.6.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <version>${springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
            <version>${springframework.version}</version>
        </dependency>

        <!-- Hibernate -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>${hibernate.version}</version>
        </dependency>

        <!-- jsr303 validation -->
        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <version>1.1.0.Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>5.1.2.Final</version>
        </dependency>

        <!-- MySQL -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>${mysql.version}</version>
        </dependency>

        <!-- JSON -->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.1.2</version>
        </dependency>
        <!-- Joda-Time -->      
        <dependency>
            <groupId>joda-time</groupId>
            <artifactId>joda-time</artifactId>
            <version>${joda-time.version}</version>
        </dependency>

        <!-- To map JodaTime with database type -->         
        <dependency>
            <groupId>org.jadira.usertype</groupId>
            <artifactId>usertype.core</artifactId>
            <version>3.0.0.CR1</version>
        </dependency>

        <!-- Servlet+JSP+JSTL -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>javax.servlet.jsp-api</artifactId>
            <version>2.3.1</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>

        <dependency> <!-- security-core for core authentication and access-control classes-->  
            <groupId>org.springframework.security</groupId>  
            <artifactId>spring-security-core</artifactId>  
            <version>3.2.3.RELEASE</version>  
        </dependency>  
        <dependency> <!-- security-web for web-security infrastructure code -->  
            <groupId>org.springframework.security</groupId>  
            <artifactId>spring-security-web</artifactId>  
            <version>3.2.3.RELEASE</version>  
        </dependency>  
        <dependency> <!-- security-config contains the security namespace parsing code -->  
            <groupId>org.springframework.security</groupId>  
            <artifactId>spring-security-config</artifactId>  
            <version>3.2.3.RELEASE</version>  
        </dependency>
        <dependency>
            <groupId>com.twilio.sdk</groupId>
            <artifactId>twilio-java-sdk</artifactId>
            <version>3.4.5</version>
        </dependency>
        <dependency>
            <groupId>javax.mail</groupId>
            <artifactId>mail</artifactId>
            <version>1.4</version>
        </dependency>
        <dependency>
            <groupId>commons-fileupload</groupId>
            <artifactId>commons-fileupload</artifactId>
            <version>1.2.2</version>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.4</version>
        </dependency>
        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-java-sdk</artifactId>
            <version>1.9.30</version>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.3.4</version>
        </dependency>
    </dependencies>
    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>2.4</version>
                    <configuration>
                        <warSourceDirectory>src/main/webapp</warSourceDirectory>
                        <warName>raghu</warName>
                        <failOnMissingWebXml>false</failOnMissingWebXml>
                    </configuration>
                </plugin>
                <plugin>
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-compiler-plugin</artifactId>
                  <version>2.1</version>
                  <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                  </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
        <finalName>raghu</finalName>
    </build>
</project>

JAVA implementation i tried

public String convertToText(MultipartFile file) throws Exception {

        SpeechClient speech = SpeechClient.create();

        byte[] data = file.getBytes();

        ByteString audioBytes = ByteString.copyFrom(data);
        System.out.println("1**********");
        // Builds the sync recognize request
        RecognitionConfig config = RecognitionConfig.newBuilder()
            .setEncoding(AudioEncoding.LINEAR16)
            .setSampleRateHertz(16000)
            .setLanguageCode("en-US")
            .build();
        RecognitionAudio audio = RecognitionAudio.newBuilder()
            .setContent(audioBytes)
            .build();

        // Performs speech recognition on the audio file
        RecognizeResponse response = speech.recognize(config, audio);
        List<SpeechRecognitionResult> results = response.getResultsList();

        String recText = "";


        for (SpeechRecognitionResult result: results) {
          List<SpeechRecognitionAlternative> alternatives = result.getAlternativesList();
          for (SpeechRecognitionAlternative alternative: alternatives) {
            System.out.printf("Transcription: %s%n", alternative.getTranscript());
            recText+= " "+alternative.getTranscript();
          }
        }
        speech.close();

        return recText;
    }

I am using to Tomcat (I don't want to use Jetty) to deploy my .war file.

There are lot of questions around the Internet none of them seems to be having the question answered! Any help would be greatly appreciated!

解决方案

Netty-tcnative 1.x is incompatible with tcnative as used by Tomcat. The incompatibility is resolved with netty-tcantive 2.x. Using the new netty-tcnative required updates to grpc-java, which will be included in the next release, 1.4.0, scheduled for June 6th.

这篇关于Jetty ALPN / NPN尚未正确配置。当试图使用谷歌云语音API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆