FAQ & Troubleshooting
Common questions, issues, and solutions when working with Azu.
Frequently Asked Questions
General Questions
Q: What makes Azu different from other web frameworks?
A: Azu emphasizes compile-time type safety and contract-first development. Unlike traditional frameworks that validate at runtime, Azu catches errors during compilation, resulting in more reliable applications with zero runtime overhead for type checking.
Q: Can I use Azu for production applications?
A: Yes! Azu is built for production use with performance optimizations, comprehensive error handling, and scalability features. Many applications are successfully running Azu in production environments.
Q: How does Azu compare to other Crystal web frameworks?
A: Azu focuses on type-safe contracts and real-time features, while frameworks like Kemal prioritize simplicity. Azu provides more structure and compile-time guarantees at the cost of some flexibility.
Q: Do I need to learn Crystal to use Azu?
A: Yes, basic Crystal knowledge is required. However, Crystal's syntax is similar to Ruby, making it approachable for developers from many backgrounds.
Technical Questions
Q: How do I handle database connections in Azu?
A: Azu doesn't include a built-in ORM. You can use any Crystal database library like crystal-db, granite, or jennifer.cr:
require "pg"
require "azu"
struct UserEndpoint
include Azu::Endpoint(UserRequest, UserResponse)
get "/users/:id"
def call : UserResponse
DB.open("postgres://localhost/mydb") do |db|
user = db.query_one("SELECT * FROM users WHERE id = $1",
params["id"], as: User)
UserResponse.new(user)
end
end
endQ: Can I use Azu with existing Crystal libraries?
A: Absolutely! Azu is designed to work with the Crystal ecosystem. You can use any Crystal shard or library within your Azu applications.
Q: How do I handle authentication?
A: Implement authentication using middleware:
Q: How do I deploy Azu applications?
A: Compile your application and deploy the binary:
Common Issues
Compilation Issues
Problem: "can't infer type" errors
Problem: Template compilation errors
Solution: Check template paths in configuration:
Runtime Issues
Problem: WebSocket connections not working
Symptoms:
WebSocket connection fails
No error messages in logs
Client can't connect
Solutions:
Check WebSocket route registration:
Verify middleware order:
Check client-side connection:
Problem: Request validation not working
Symptoms:
Validation rules ignored
Invalid data passes through
Solutions:
Ensure validation is called:
Check validation rules syntax:
Problem: File uploads not working
Symptoms:
File uploads fail silently
Uploaded files are empty
Memory issues with large files
Solutions:
Configure upload limits:
Handle multipart data correctly:
Performance Issues
Problem: Slow response times
Diagnosis:
Enable request logging:
Check for blocking operations:
Problem: Memory leaks
Common causes:
Not cleaning up file uploads
Keeping references to WebSocket connections
Large object creation in loops
Solutions:
Clean up resources:
Manage WebSocket connections:
Development Issues
Problem: Hot reload not working
Solutions:
Enable in configuration:
Check file permissions and paths:
Problem: CORS issues in development
Symptoms:
Browser blocks requests from frontend
CORS errors in console
Solution:
Debugging Tips
Enable Debug Logging
Inspect Request Data
Use Crystal's Built-in Debugging
Test Individual Components
Performance Troubleshooting
Profile Your Application
Monitor Memory Usage
Database Query Optimization
Getting Help
Community Resources
GitHub Issues: azutoolkit/azu/issues
Crystal Community: Crystal Language Forum
Documentation: Official Azu Docs
Reporting Issues
When reporting issues, include:
Crystal version:
crystal versionAzu version: Check
shard.ymlMinimal reproduction case
Error messages and stack traces
Environment details (OS, deployment method)
Example Issue Report
Error: Connection refused when trying to connect to ws://localhost:4000/test
Expected: WebSocket connection should succeed
Last updated
Was this helpful?
