问题标签 [ktor]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
firebase - Firebase Auth Not Working With Ktor App On AppEngine
Issue
When deploying a Ktor Kotlin application to AppEngine per the Ktor tutorial, the Firestore server authentication is not working, thus data is not being written to the specified Firestore database.
Data is written as expected to Firestore both when the app is run directly in the IntelliJ IDE as well as when it is run with ktor's implementation via the gradle appengineRun
command.
There are two sets of AppEngine/Firebase projects for both a staging and production environment. Prior to deploying with the gradle appengineDeploy
command the correct SDK configuration been activated and verified via the command gcloud config configurations list.
The strange part is that a few of the apps deployed with these strategies did write to Firestore, however upon deploying the app again Firestore did not show new data being written to it.
Implementation
Ktor Setup
I have the standard ktor required files. I also have an old MANIFEST.MF file from an older implementation. Could that be causing issues?
src/main/resources/application.conf
src/main/resources/webapp/WEB-INF/
appengine-web.xml
web.xml
logging.properties
.level = INFO
src/main/META-INF/MANIFEST>MF
Dependencies
For authentication strategies outlined below #1-3 the Firebase Admin library is used: compile 'com.google.firebase:firebase-admin:6.5.0'
For authentication strategy #4 the Google Cloud Firestore library is used: compile 'com.google.cloud:google-cloud-firestore:0.58.0-beta'
build.gradle
Initializing Firebase Strategies
1. Initialize on Google Cloud Platform
This method is promising as credentials are managed automatically.
2. Initialize on your own server
I've confirmed in GCPs IAM & admin > Service accounts that the key id's match with the Json object being used to authenticate.
I'm using this strategy successfully in another Firestore connected app deployed to AppEngine. The working app is built as a .Jar and deployed directly to AppEngine without using ktor, but rather with the steps outlined here.
In my working .Jar built app I'm passing in the Json object programmatically to avoid issues with the file not being found. I tried the same programmatic implementation for this ktor application. It worked with gradle appengineRun
but not when deployed.
3. Initialize on your own server (Firebase console setup)
The only difference between #2 is this setup adds .setDatabaseUrl("https://yourProjectName.firebaseio.com")
.
Accessing Firestore Object
For #1-3 the Firebase app is initialized right away in the application's main() method. Then, the Firestore object is accessed from an object.
FirebaseClient.Kt
For #4 the Firestore object is created in the Kotlin object's init{...}
and stored in the object as a value.
FirebaseClient.Kt
Writing to Firestore
FirebaseClient.firestore.collection(someCollection).document(someDocument).collection(anotherCollection).add(someObject)
json - Ktor:在多平台中以 List 为根序列化/反序列化 JSON
我们如何使用 kotlin.serialize 和 Ktor 的 HttpClient 来反序列化/序列化 JSON 并以列表为根?我正在按如下方式创建 HttpClient:
似乎我需要为 List 设置映射器,但是这对于泛型是不可能的。我看到我可以使用 MyClass.serializer().list 为它获取序列化程序,但是将其注册为对 http 请求进行反序列化/序列化并不简单。有人知道一个好的解决方案吗?
mysql - java.sql.SQLException:无法加载身份验证插件“caching_sha2_password”
我正在尝试在 Ktor 应用程序中连接到 MySQL 数据库:
...
但我收到以下错误:
java.sql.SQLException:无法加载身份验证插件“caching_sha2_password”
为什么会这样?以及如何解决?
UPD
最终我找到了修复它的方法:我通过命令在 MySQL 中创建了新用户
然后授予他所有权限并使用新凭据重新连接。但是第一个问题仍然是实际的,因为我没有任何设置
在我的my.ini文件中。
kotlin - 如何在 ktor http 客户端记录请求?
我得到了这样的东西:
并提出要求
但我需要检查请求和响应正文,有什么办法吗?在控制台/文件中?
kotlin - gRPC over TLS 使用 Netty/Kortlin/Ktor 引发错误并阻止 gNMI 工作
目前正在开发一个带有 gRPC/gNMI + Kotlin 和 Ktor HTTP 的模块。使用安全的依赖库 tc-native netty-tcnative-boringssl-static 2.0.19-Final
Ktor 在 1.0.0-beta3
使用 gRPC 请求时
它给出以下错误(堆栈跟踪):
请任何想法来解决这个问题?谢谢
kotlin - 将 url 的内容添加到 Ktor 中的 respondText
我有一个url ,我想使用Ktor框架显示为我的网页内容。
提前致谢。
servlets - 如何在 Ktor 中注册一个 servlet?
我正在寻找一种在 ktor 中注册 javax.servlet.http.HttpServlet 的方法,但找不到任何方法。
我需要安装一个功能吗?在路由中注册它?我可以启用@WebServlet
注释扫描吗?
小服务程序示例:
java - KTor Gson DataConversion 带接口
我正在尝试PubicKey
在 KTor 中注册用于数据转换的接口,以便我可以轻松地接收这样的公钥:
为了实现这一点,我使用了这个页面:https
://ktor.io/servers/features/data-conversion.html
我注册了这个数据转换器:
但由于某种原因,Gson 抱怨,因为我正在使用一个界面:
所以我猜我需要InstanceCreator
为初始值创建一个。这是PublicKey
我创建的初始类:
但这也行不通!这是我得到的例外:
出于某种原因,它期望提供的密钥是一个 JSON 对象,而我正在提供这个:
我怎样才能“欺骗”GSON 接受一个字符串PublicKey
?还是我做错了什么?
我认为 GSON 想要将 JSON 对象序列化为PublicKey
. 但我希望它接受一个String
. 我认为这应该是可能的,因为类喜欢UUID
并且Date
工作得很好......
xml - 需要使用 Ktor 框架将 Saber API 集成到 SOAP xml 中
我需要使用 Ktor 框架(Kotlin)将 saber API 集成到 SOAP xml 中,我无法找到任何有关此的文档。我正在寻找有关 KTOR 与 SOAP XML API 集成的帮助。